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

pull/88614/head
Karl Persson 12 months ago committed by GitHub
parent 221e036233
commit 68f2585712
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      pkg/cmd/grafana-cli/commands/reset_password_command.go

@ -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)
}

Loading…
Cancel
Save