aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorJorropo <admin@jorropo.ovh>2018-09-04 16:34:01 +0200
committerChocobozzz <me@florianbigard.com>2018-09-04 17:11:48 +0200
commita94419a604f324305c9dbb607496a5bca9b63d04 (patch)
treedc647eb017dda542e770de59e503f86c3ef39c6d /client/src
parentc75937d04f0a45b1ba169d28d0854ad33cfee900 (diff)
downloadPeerTube-a94419a604f324305c9dbb607496a5bca9b63d04.tar.gz
PeerTube-a94419a604f324305c9dbb607496a5bca9b63d04.tar.zst
PeerTube-a94419a604f324305c9dbb607496a5bca9b63d04.zip
Making password change erroring more friendly
If you leave the form but the 2 password is different a big red boxappears to warn you (no need to click on the button).The submit buttonis desactivated if the 2 password isn't the same.
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.html5
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts28
2 files changed, 24 insertions, 9 deletions
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 767ef0336..913b570cb 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
@@ -6,6 +6,7 @@
6 <input 6 <input
7 type="password" id="new-password" i18n-placeholder placeholder="New password" 7 type="password" id="new-password" i18n-placeholder placeholder="New password"
8 formControlName="new-password" [ngClass]="{ 'input-error': formErrors['new-password'] }" 8 formControlName="new-password" [ngClass]="{ 'input-error': formErrors['new-password'] }"
9 (change)="validateNewPassword()" (blur)="printAnError()"
9 > 10 >
10 <div *ngIf="formErrors['new-password']" class="form-error"> 11 <div *ngIf="formErrors['new-password']" class="form-error">
11 {{ formErrors['new-password'] }} 12 {{ formErrors['new-password'] }}
@@ -13,8 +14,8 @@
13 14
14 <input 15 <input
15 type="password" id="new-confirmed-password" i18n-placeholder placeholder="Confirm new password" 16 type="password" id="new-confirmed-password" i18n-placeholder placeholder="Confirm new password"
16 formControlName="new-confirmed-password" 17 formControlName="new-confirmed-password" (change)="validateNewPassword()" (blur)="printAnError()"
17 > 18 >
18 19
19 <input type="submit" i18n-value value="Change password" [disabled]="!form.valid"> 20 <input type="submit" i18n-value value="Change password" [disabled]="!form.valid || unsendable">
20</form> 21</form>
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})
13export class MyAccountChangePasswordComponent extends FormReactive implements OnInit { 13export 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