From: BO41 Date: Sat, 22 Sep 2018 13:46:33 +0000 (+0200) Subject: check old password before change X-Git-Tag: v1.0.0-beta.16~38 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3805ce3f4335e89f63ddb6cd166f14ba120d9c83;p=oweals%2Fpeertube.git check old password before change --- diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.html b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.html index ab6df52be..00b6d20fa 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.html +++ b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.html @@ -1,8 +1,16 @@
{{ error }}
-
+ + +
+ {{ formErrors['old-password'] }} +
+ confirmPasswordControl.setErrors({ matchPassword: true })) } - changePassword () { + checkPassword () { + this.error = null + const oldPassword = this.form.value[ 'old-password' ]; + + // compare old password + this.authService.login(this.user.account.name, oldPassword) + .subscribe( + () => this.changePassword(), + err => { + if (err.message.indexOf('credentials are invalid') !== -1) this.error = this.i18n('Incorrect old password.') + else this.error = err.message + } + ) + + } + + private changePassword(){ this.userService.changePassword(this.form.value[ 'new-password' ]).subscribe( () => { this.notificationsService.success(this.i18n('Success'), this.i18n('Password updated.'))