Cli: Fix bug where password is hashed twice (#88589)

This commit is contained in:
Karl Persson 2024-06-03 09:14:55 +02:00 committed by GitHub
parent 221e036233
commit 68f2585712
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,7 +47,7 @@ func resetPasswordCommand(c utils.CommandLine, runner server.Runner) error {
return err
}
func resetPassword(adminId int64, newPassword user.Password, userSvc user.Service) error {
func resetPassword(adminId int64, password user.Password, userSvc user.Service) error {
userQuery := user.GetUserByIDQuery{ID: adminId}
usr, err := userSvc.GetByID(context.Background(), &userQuery)
if err != nil {
@ -57,11 +57,6 @@ func resetPassword(adminId int64, newPassword user.Password, userSvc user.Servic
return ErrMustBeAdmin
}
password, err := newPassword.Hash(usr.Salt)
if err != nil {
return err
}
if err := userSvc.Update(context.Background(), &user.UpdateUserCommand{UserID: adminId, Password: &password}); err != nil {
return fmt.Errorf("failed to update user password: %w", err)
}