diff options
Diffstat (limited to 'client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts')
-rw-r--r-- | client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts index 7be7aabc2..0707d8f9a 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts | |||
@@ -12,6 +12,7 @@ import { UserValidatorsService } from '@app/shared/forms/form-validators/user-va | |||
12 | }) | 12 | }) |
13 | export class MyAccountChangePasswordComponent extends FormReactive implements OnInit { | 13 | export class MyAccountChangePasswordComponent extends FormReactive implements OnInit { |
14 | error: string = null | 14 | error: string = null |
15 | unsendable = true // default to true to not have to not the if in change password | ||
15 | 16 | ||
16 | constructor ( | 17 | constructor ( |
17 | protected formValidatorService: FormValidatorService, | 18 | protected formValidatorService: FormValidatorService, |
@@ -30,18 +31,31 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On | |||
30 | }) | 31 | }) |
31 | } | 32 | } |
32 | 33 | ||
33 | changePassword () { | 34 | validateNewPassword () { |
34 | const newPassword = this.form.value['new-password'] | 35 | if (this.form.value['new-password'] && this.form.value['new-confirmed-password']) { |
35 | const newConfirmedPassword = this.form.value['new-confirmed-password'] | 36 | if (this.form.value['new-password'] === this.form.value['new-confirmed-password']) { |
36 | 37 | this.error = null | |
37 | this.error = null | 38 | this.unsendable = false |
39 | return | ||
40 | } | ||
41 | } | ||
42 | this.unsendable = true | ||
43 | } | ||
38 | 44 | ||
39 | if (newPassword !== newConfirmedPassword) { | 45 | printAnError () { |
46 | console.log(this.unsendable) | ||
47 | this.validateNewPassword() | ||
48 | if (this.unsendable) { | ||
40 | this.error = this.i18n('The new password and the confirmed password do not correspond.') | 49 | this.error = this.i18n('The new password and the confirmed password do not correspond.') |
50 | } | ||
51 | } | ||
52 | |||
53 | changePassword () { | ||
54 | if (this.unsendable) { | ||
41 | return | 55 | return |
42 | } | 56 | } |
43 | 57 | ||
44 | this.userService.changePassword(newPassword).subscribe( | 58 | this.userService.changePassword(this.form.value['new-password']).subscribe( |
45 | () => this.notificationsService.success(this.i18n('Success'), this.i18n('Password updated.')), | 59 | () => this.notificationsService.success(this.i18n('Success'), this.i18n('Password updated.')), |
46 | 60 | ||
47 | err => this.error = err.message | 61 | err => this.error = err.message |