Creating new admin user from CLI

go run ./cmd/migrate new admin
This commit is contained in:
cdricms
2025-02-26 12:51:29 +01:00
parent efec258ae3
commit 667cbcc6b1
2 changed files with 148 additions and 7 deletions

View File

@@ -32,10 +32,11 @@ type User struct {
}
func (u *User) Insert(db *bun.DB, ctx context.Context) (sql.Result, error) {
u.Password = fmt.Sprintf("crypt('%s', gen_salt('bf'))", u.Password)
return db.NewInsert().
Model(u).
Value("password", u.Password).
Value("password", "crypt(?, gen_salt('bf'))", u.Password).
Ignore().
// Returning("user_id").
Exec(ctx)
}