[SG-414] Weak password prompt not displaying on master password reset (#3241)
* moved password strength to libs * refactored password strength component * made changes on desktop and browser to reuse component * resolved suggestions from PR review * shared module restructure * shared module restructure * Fixed no warning prompt on reset password * SG-519 setting new password warning prompt fix * removed any and added type
This commit is contained in:
parent
ecd6863abe
commit
31cae4390f
|
@ -28,6 +28,7 @@
|
||||||
[password]="masterPassword"
|
[password]="masterPassword"
|
||||||
[email]="email"
|
[email]="email"
|
||||||
[showText]="true"
|
[showText]="true"
|
||||||
|
(passwordStrengthResult)="getStrengthResult($event)"
|
||||||
>
|
>
|
||||||
</app-password-strength>
|
</app-password-strength>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -77,7 +77,12 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<app-password-strength [password]="newPassword" [email]="email" [showText]="true">
|
<app-password-strength
|
||||||
|
[password]="newPassword"
|
||||||
|
[email]="email"
|
||||||
|
[showText]="true"
|
||||||
|
(passwordStrengthResult)="getStrengthResult($event)"
|
||||||
|
>
|
||||||
</app-password-strength>
|
</app-password-strength>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from "@angular/core";
|
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from "@angular/core";
|
||||||
|
import zxcvbn from "zxcvbn";
|
||||||
|
|
||||||
import { PasswordStrengthComponent } from "@bitwarden/angular/shared/components/password-strength/password-strength.component";
|
import { PasswordStrengthComponent } from "@bitwarden/angular/shared/components/password-strength/password-strength.component";
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
|
@ -28,7 +29,7 @@ export class ResetPasswordComponent implements OnInit {
|
||||||
enforcedPolicyOptions: MasterPasswordPolicyOptions;
|
enforcedPolicyOptions: MasterPasswordPolicyOptions;
|
||||||
newPassword: string = null;
|
newPassword: string = null;
|
||||||
showPassword = false;
|
showPassword = false;
|
||||||
masterPasswordScore: number;
|
passwordStrengthResult: zxcvbn.ZXCVBNResult;
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<any>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -97,7 +98,7 @@ export class ResetPasswordComponent implements OnInit {
|
||||||
if (
|
if (
|
||||||
this.enforcedPolicyOptions != null &&
|
this.enforcedPolicyOptions != null &&
|
||||||
!this.policyService.evaluateMasterPassword(
|
!this.policyService.evaluateMasterPassword(
|
||||||
this.masterPasswordScore,
|
this.passwordStrengthResult.score,
|
||||||
this.newPassword,
|
this.newPassword,
|
||||||
this.enforcedPolicyOptions
|
this.enforcedPolicyOptions
|
||||||
)
|
)
|
||||||
|
@ -110,7 +111,7 @@ export class ResetPasswordComponent implements OnInit {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.masterPasswordScore < 3) {
|
if (this.passwordStrengthResult.score < 3) {
|
||||||
const result = await this.platformUtilsService.showDialog(
|
const result = await this.platformUtilsService.showDialog(
|
||||||
this.i18nService.t("weakMasterPasswordDesc"),
|
this.i18nService.t("weakMasterPasswordDesc"),
|
||||||
this.i18nService.t("weakMasterPassword"),
|
this.i18nService.t("weakMasterPassword"),
|
||||||
|
@ -184,4 +185,8 @@ export class ResetPasswordComponent implements OnInit {
|
||||||
this.logService.error(e);
|
this.logService.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getStrengthResult(result: zxcvbn.ZXCVBNResult) {
|
||||||
|
this.passwordStrengthResult = result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue