From 68f2585712350d6e5a8a6f7f2661885a5120bb56 Mon Sep 17 00:00:00 2001 From: Karl Persson Date: Mon, 3 Jun 2024 09:14:55 +0200 Subject: [PATCH] Cli: Fix bug where password is hashed twice (#88589) --- pkg/cmd/grafana-cli/commands/reset_password_command.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/cmd/grafana-cli/commands/reset_password_command.go b/pkg/cmd/grafana-cli/commands/reset_password_command.go index 78f0ef6b0df..0a6cfbaae06 100644 --- a/pkg/cmd/grafana-cli/commands/reset_password_command.go +++ b/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) }