From 7e542258ee56cb0109dd53dbc5aa81251f3d0c5d Mon Sep 17 00:00:00 2001 From: Steven Zou Date: Sat, 1 Apr 2017 16:18:42 +0800 Subject: [PATCH] fix issue 1897: password validation enhancement --- .../account/password/password-setting.component.ts | 11 +++++++---- .../app/account/password/reset-password.component.ts | 7 +++++-- .../shared/new-user-form/new-user-form.component.ts | 9 +++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/ui_ng/src/app/account/password/password-setting.component.ts b/src/ui_ng/src/app/account/password/password-setting.component.ts index 38b3c191c..614231d2c 100644 --- a/src/ui_ng/src/app/account/password/password-setting.component.ts +++ b/src/ui_ng/src/app/account/password/password-setting.component.ts @@ -65,10 +65,13 @@ export class PasswordSettingComponent implements AfterViewChecked { let cont = this.pwdForm.controls[key]; if (cont) { this.validationStateMap[key] = cont.valid; - if (key === "reNewPassword" && cont.valid) { - let compareCont = this.pwdForm.controls["newPassword"]; - if (compareCont) { - this.validationStateMap[key] = cont.value === compareCont.value; + if (cont.valid) { + if (key === "reNewPassword" || key === "newPassword") { + let cpKey = key === "reNewPassword" ? "newPassword" : "reNewPassword"; + let compareCont = this.pwdForm.controls[cpKey]; + if (compareCont && compareCont.valid) { + this.validationStateMap["reNewPassword"] = cont.value === compareCont.value; + } } } } diff --git a/src/ui_ng/src/app/account/password/reset-password.component.ts b/src/ui_ng/src/app/account/password/reset-password.component.ts index df0a12ab5..c30732992 100644 --- a/src/ui_ng/src/app/account/password/reset-password.component.ts +++ b/src/ui_ng/src/app/account/password/reset-password.component.ts @@ -74,7 +74,7 @@ export class ResetPasswordComponent implements OnInit { } public close(): void { - //If already reset password ok, navigator to sign-in + //If already reset password ok, navigator to sign-in if (this.resetOk) { this.router.navigateByUrl(CommonRoutes.EMBEDDED_SIGN_IN); } @@ -114,7 +114,10 @@ export class ResetPasswordComponent implements OnInit { this.validationState[key] = true; } } else { - this.validationState[key] = this.getControlValidationState(key) + this.validationState[key] = this.getControlValidationState(key); + if (this.validationState[key]) { + this.validationState["reNewPassword"] = this.samePassword(); + } } } diff --git a/src/ui_ng/src/app/shared/new-user-form/new-user-form.component.ts b/src/ui_ng/src/app/shared/new-user-form/new-user-form.component.ts index 77fbdcdff..d536c26e7 100644 --- a/src/ui_ng/src/app/shared/new-user-form/new-user-form.component.ts +++ b/src/ui_ng/src/app/shared/new-user-form/new-user-form.component.ts @@ -142,10 +142,11 @@ export class NewUserFormComponent implements AfterViewChecked, OnInit { } //Check password confirmation - if (key === "confirmPassword") { - let peerCont = this.newUserForm.controls["newPassword"]; - if (peerCont) { - this.validationStateMap[key] = cont.value === peerCont.value; + if (key === "confirmPassword" || key === "newPassword") { + let cpKey = key === "confirmPassword" ? "newPassword" : "confirmPassword"; + let peerCont = this.newUserForm.controls[cpKey]; + if (peerCont && peerCont.valid) { + this.validationStateMap["confirmPassword"] = cont.value === peerCont.value; } } }