Fix double change password calls (#50948) (#50957)

(cherry picked from commit 32103fcd9f)

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2022-06-16 17:32:11 +02:00
committed by GitHub
co-authored by Jguer
parent 22fb1a7b2b
commit e3b490f47c
+13 -13
View File
@@ -61,7 +61,19 @@ export class LoginCtrl extends PureComponent<Props, State> {
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<Props, State> {
})
.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) => {