mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-01-23 21:19:31 -06:00
Hash user password in UpdateUser function
This commit is contained in:
@@ -4,10 +4,19 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/eduardolat/pgbackweb/internal/database/dbgen"
|
||||
"github.com/eduardolat/pgbackweb/internal/util/cryptoutil"
|
||||
)
|
||||
|
||||
func (s *Service) UpdateUser(
|
||||
ctx context.Context, params dbgen.UsersServiceUpdateUserParams,
|
||||
) (dbgen.User, error) {
|
||||
if params.Password.Valid {
|
||||
hashedPassword, err := cryptoutil.CreateBcryptHash(params.Password.String)
|
||||
if err != nil {
|
||||
return dbgen.User{}, err
|
||||
}
|
||||
params.Password.String = hashedPassword
|
||||
}
|
||||
|
||||
return s.dbgen.UsersServiceUpdateUser(ctx, params)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user