fix(user): change username (#1502)

* fix(user): change username

* fix(user): api client error improvements

* fix(user): api client error improvements
This commit is contained in:
ze0s 2024-04-12 15:09:40 +02:00 committed by GitHub
parent da53230077
commit 5857945e71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 14 deletions

View file

@ -134,12 +134,14 @@ func (s *service) UpdateUser(ctx context.Context, req domain.UpdateUserRequest)
return errors.Errorf("invalid login: %s", req.UsernameCurrent)
}
hashed, err := s.CreateHash(req.PasswordNew)
if err != nil {
return errors.New("failed to hash password")
}
if req.PasswordNew != "" {
hashed, err := s.CreateHash(req.PasswordNew)
if err != nil {
return errors.New("failed to hash password")
}
req.PasswordNewHash = hashed
req.PasswordNewHash = hashed
}
if err := s.userSvc.Update(ctx, req); err != nil {
s.log.Error().Err(err).Msgf("could not change password for user: %s", req.UsernameCurrent)