1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-06 10:33:57 +00:00

Update complexity score display (#479)

* Update complexity score

* Simplifying switch statement
This commit is contained in:
Vincent Salucci
2020-03-03 15:37:54 -06:00
committed by GitHub
parent e7e5816ded
commit 305d86f765
6 changed files with 52 additions and 6 deletions

View File

@@ -3,7 +3,7 @@
<p>{{'masterPasswordPolicyInEffect' | i18n}}</p>
<ul>
<li *ngIf="enforcedPolicyOptions?.minComplexity > 0">
{{'policyInEffectMinComplexity' | i18n : enforcedPolicyOptions?.minComplexity.toString()}}
{{'policyInEffectMinComplexity' | i18n : getPasswordScoreAlertDisplay()}}
</li>
<li *ngIf="enforcedPolicyOptions?.minLength > 0">
{{'policyInEffectMinLength' | i18n : enforcedPolicyOptions?.minLength.toString()}}

View File

@@ -56,6 +56,23 @@ export class ChangePasswordComponent implements OnInit {
this.enforcedPolicyOptions = await this.policyService.getMasterPasswordPolicyOptions();
}
getPasswordScoreAlertDisplay() {
if (this.enforcedPolicyOptions == null) {
return '';
}
let str: string;
switch (this.enforcedPolicyOptions.minComplexity) {
case 4:
str = this.i18nService.t('strong');
case 3:
str = this.i18nService.t('good');
default:
str = this.i18nService.t('weak');
}
return str + ' (' + this.enforcedPolicyOptions.minComplexity + ')';
}
async submit() {
const hasEncKey = await this.cryptoService.hasEncKey();
if (!hasEncKey) {