From 305d86f765f27d44c6568e06a6e1f04f8b3c9848 Mon Sep 17 00:00:00 2001
From: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com>
Date: Tue, 3 Mar 2020 15:37:54 -0600
Subject: [PATCH] Update complexity score display (#479)
* Update complexity score
* Simplifying switch statement
---
src/app/accounts/register.component.html | 2 +-
src/app/accounts/register.component.ts | 19 ++++++++++++++++++-
.../manage/policy-edit.component.html | 6 ++++--
.../manage/policy-edit.component.ts | 12 +++++++++++-
.../settings/change-password.component.html | 2 +-
src/app/settings/change-password.component.ts | 17 +++++++++++++++++
6 files changed, 52 insertions(+), 6 deletions(-)
diff --git a/src/app/accounts/register.component.html b/src/app/accounts/register.component.html
index 657f5af004..b9d107e9c0 100644
--- a/src/app/accounts/register.component.html
+++ b/src/app/accounts/register.component.html
@@ -25,7 +25,7 @@
{{'masterPasswordPolicyInEffect' | i18n}}
- 0">
- {{'policyInEffectMinComplexity' | i18n : enforcedPolicyOptions?.minComplexity.toString()}}
+ {{'policyInEffectMinComplexity' | i18n : getPasswordScoreAlertDisplay()}}
- 0">
{{'policyInEffectMinLength' | i18n : enforcedPolicyOptions?.minLength.toString()}}
diff --git a/src/app/accounts/register.component.ts b/src/app/accounts/register.component.ts
index a0080475dc..d555842d2d 100644
--- a/src/app/accounts/register.component.ts
+++ b/src/app/accounts/register.component.ts
@@ -27,9 +27,9 @@ import { PolicyData } from 'jslib/models/data/policyData';
export class RegisterComponent extends BaseRegisterComponent {
showCreateOrgMessage = false;
showTerms = true;
+ enforcedPolicyOptions: MasterPasswordPolicyOptions;
private policies: Policy[];
- enforcedPolicyOptions: MasterPasswordPolicyOptions;
constructor(authService: AuthService, router: Router,
i18nService: I18nService, cryptoService: CryptoService,
@@ -41,6 +41,23 @@ export class RegisterComponent extends BaseRegisterComponent {
this.showTerms = !platformUtilsService.isSelfHost();
}
+ 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 ngOnInit() {
const queryParamsSub = this.route.queryParams.subscribe((qParams) => {
if (qParams.email != null && qParams.email.indexOf('@') > -1) {
diff --git a/src/app/organizations/manage/policy-edit.component.html b/src/app/organizations/manage/policy-edit.component.html
index 23c3277756..ee3be52f99 100644
--- a/src/app/organizations/manage/policy-edit.component.html
+++ b/src/app/organizations/manage/policy-edit.component.html
@@ -28,8 +28,10 @@