mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-05-05 11:09:11 -05:00
Update CreateUser function to hash user password using bcrypt
This commit is contained in:
@@ -4,10 +4,17 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/eduardolat/pgbackweb/internal/database/dbgen"
|
||||
"github.com/eduardolat/pgbackweb/internal/util/cryptoutil"
|
||||
)
|
||||
|
||||
func (s *Service) CreateUser(
|
||||
ctx context.Context, params dbgen.UsersServiceCreateUserParams,
|
||||
) (dbgen.User, error) {
|
||||
hash, err := cryptoutil.CreateBcryptHash(params.Password)
|
||||
if err != nil {
|
||||
return dbgen.User{}, err
|
||||
}
|
||||
params.Password = hash
|
||||
|
||||
return s.dbgen.UsersServiceCreateUser(ctx, params)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user