Update CreateUser function to hash user password using bcrypt

This commit is contained in:
Luis Eduardo Jeréz Girón
2024-07-20 17:33:03 -06:00
parent a712669578
commit b16142a509
+7
View File
@@ -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)
}