Fix double change password calls (#50948)

This commit is contained in:
Jguer 2022-06-16 14:30:33 +00:00 committed by GitHub
parent 5a35381f77
commit 32103fcd9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,7 +61,19 @@ export class LoginCtrl extends PureComponent<Props, State> {
oldPassword: 'admin', 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() getBackendSrv()
.put('/api/user/password', pw) .put('/api/user/password', pw)
.then(() => { .then(() => {
@ -69,18 +81,6 @@ export class LoginCtrl extends PureComponent<Props, State> {
}) })
.catch((err: any) => console.error(err)); .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) => { login = (formModel: FormModel) => {