From 32103fcd9ff0a3d22c962da053e6596c6e23bf63 Mon Sep 17 00:00:00 2001 From: Jguer Date: Thu, 16 Jun 2022 14:30:33 +0000 Subject: [PATCH] Fix double change password calls (#50948) --- .../app/core/components/Login/LoginCtrl.tsx | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/public/app/core/components/Login/LoginCtrl.tsx b/public/app/core/components/Login/LoginCtrl.tsx index c7277237833..cc6bf390255 100644 --- a/public/app/core/components/Login/LoginCtrl.tsx +++ b/public/app/core/components/Login/LoginCtrl.tsx @@ -61,7 +61,19 @@ export class LoginCtrl extends PureComponent { oldPassword: 'admin', }; - if (!this.props.resetCode) { + if (this.props.resetCode) { + const resetModel = { + code: this.props.resetCode, + newPassword: password, + confirmPassword: password, + }; + + getBackendSrv() + .post('/api/user/password/reset', resetModel) + .then(() => { + this.toGrafana(); + }); + } else { getBackendSrv() .put('/api/user/password', pw) .then(() => { @@ -69,18 +81,6 @@ export class LoginCtrl extends PureComponent { }) .catch((err: any) => console.error(err)); } - - const resetModel = { - code: this.props.resetCode, - newPassword: password, - confirmPassword: password, - }; - - getBackendSrv() - .post('/api/user/password/reset', resetModel) - .then(() => { - this.toGrafana(); - }); }; login = (formModel: FormModel) => {