From 3805ce3f4335e89f63ddb6cd166f14ba120d9c83 Mon Sep 17 00:00:00 2001 From: BO41 Date: Sat, 22 Sep 2018 15:46:33 +0200 Subject: check old password before change --- .../my-account-change-password.component.html | 10 ++++++++- .../my-account-change-password.component.scss | 3 ++- .../my-account-change-password.component.ts | 25 +++++++++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) (limited to 'client/src/app/+my-account') 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.')) -- cgit v1.2.3