Update complexity score display (#479)
* Update complexity score * Simplifying switch statement
This commit is contained in:
parent
e7e5816ded
commit
305d86f765
|
@ -25,7 +25,7 @@
|
||||||
<p>{{'masterPasswordPolicyInEffect' | i18n}}</p>
|
<p>{{'masterPasswordPolicyInEffect' | i18n}}</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li *ngIf="enforcedPolicyOptions?.minComplexity > 0">
|
<li *ngIf="enforcedPolicyOptions?.minComplexity > 0">
|
||||||
{{'policyInEffectMinComplexity' | i18n : enforcedPolicyOptions?.minComplexity.toString()}}
|
{{'policyInEffectMinComplexity' | i18n : getPasswordScoreAlertDisplay()}}
|
||||||
</li>
|
</li>
|
||||||
<li *ngIf="enforcedPolicyOptions?.minLength > 0">
|
<li *ngIf="enforcedPolicyOptions?.minLength > 0">
|
||||||
{{'policyInEffectMinLength' | i18n : enforcedPolicyOptions?.minLength.toString()}}
|
{{'policyInEffectMinLength' | i18n : enforcedPolicyOptions?.minLength.toString()}}
|
||||||
|
|
|
@ -27,9 +27,9 @@ import { PolicyData } from 'jslib/models/data/policyData';
|
||||||
export class RegisterComponent extends BaseRegisterComponent {
|
export class RegisterComponent extends BaseRegisterComponent {
|
||||||
showCreateOrgMessage = false;
|
showCreateOrgMessage = false;
|
||||||
showTerms = true;
|
showTerms = true;
|
||||||
|
enforcedPolicyOptions: MasterPasswordPolicyOptions;
|
||||||
|
|
||||||
private policies: Policy[];
|
private policies: Policy[];
|
||||||
enforcedPolicyOptions: MasterPasswordPolicyOptions;
|
|
||||||
|
|
||||||
constructor(authService: AuthService, router: Router,
|
constructor(authService: AuthService, router: Router,
|
||||||
i18nService: I18nService, cryptoService: CryptoService,
|
i18nService: I18nService, cryptoService: CryptoService,
|
||||||
|
@ -41,6 +41,23 @@ export class RegisterComponent extends BaseRegisterComponent {
|
||||||
this.showTerms = !platformUtilsService.isSelfHost();
|
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() {
|
async ngOnInit() {
|
||||||
const queryParamsSub = this.route.queryParams.subscribe((qParams) => {
|
const queryParamsSub = this.route.queryParams.subscribe((qParams) => {
|
||||||
if (qParams.email != null && qParams.email.indexOf('@') > -1) {
|
if (qParams.email != null && qParams.email.indexOf('@') > -1) {
|
||||||
|
|
|
@ -28,8 +28,10 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6 form-group">
|
<div class="col-6 form-group">
|
||||||
<label for="masterPassMinComplexity">{{'minComplexityScore' | i18n}}</label>
|
<label for="masterPassMinComplexity">{{'minComplexityScore' | i18n}}</label>
|
||||||
<input id="masterPassMinComplexity" class="form-control" type="number"
|
<select id="masterPassMinComplexity" name="MasterPassMinComplexity"
|
||||||
name="MasterPassMinComplexity" [(ngModel)]="masterPassMinComplexity" min="0" max="4">
|
[(ngModel)]="masterPassMinComplexity" class="form-control">
|
||||||
|
<option *ngFor="let o of passwordScores" [ngValue]="o.value">{{o.name}}</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6 form-group">
|
<div class="col-6 form-group">
|
||||||
<label for="masterPassMinLength">{{'minLength' | i18n}}</label>
|
<label for="masterPassMinLength">{{'minLength' | i18n}}</label>
|
||||||
|
|
|
@ -33,6 +33,7 @@ export class PolicyEditComponent implements OnInit {
|
||||||
loading = true;
|
loading = true;
|
||||||
enabled = false;
|
enabled = false;
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<any>;
|
||||||
|
passwordScores: any[];
|
||||||
|
|
||||||
// Master password
|
// Master password
|
||||||
|
|
||||||
|
@ -56,7 +57,16 @@ export class PolicyEditComponent implements OnInit {
|
||||||
private policy: PolicyResponse;
|
private policy: PolicyResponse;
|
||||||
|
|
||||||
constructor(private apiService: ApiService, private i18nService: I18nService,
|
constructor(private apiService: ApiService, private i18nService: I18nService,
|
||||||
private analytics: Angulartics2, private toasterService: ToasterService) { }
|
private analytics: Angulartics2, private toasterService: ToasterService) {
|
||||||
|
this.passwordScores = [
|
||||||
|
{ name: '', value: null },
|
||||||
|
{ name: i18nService.t('weak') + ' (0)', value: 0 },
|
||||||
|
{ name: i18nService.t('weak') + ' (1)', value: 1 },
|
||||||
|
{ name: i18nService.t('weak') + ' (2)', value: 2 },
|
||||||
|
{ name: i18nService.t('good') + ' (3)', value: 3 },
|
||||||
|
{ name: i18nService.t('strong') + ' (4)', value: 4 },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
await this.load();
|
await this.load();
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<p>{{'masterPasswordPolicyInEffect' | i18n}}</p>
|
<p>{{'masterPasswordPolicyInEffect' | i18n}}</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li *ngIf="enforcedPolicyOptions?.minComplexity > 0">
|
<li *ngIf="enforcedPolicyOptions?.minComplexity > 0">
|
||||||
{{'policyInEffectMinComplexity' | i18n : enforcedPolicyOptions?.minComplexity.toString()}}
|
{{'policyInEffectMinComplexity' | i18n : getPasswordScoreAlertDisplay()}}
|
||||||
</li>
|
</li>
|
||||||
<li *ngIf="enforcedPolicyOptions?.minLength > 0">
|
<li *ngIf="enforcedPolicyOptions?.minLength > 0">
|
||||||
{{'policyInEffectMinLength' | i18n : enforcedPolicyOptions?.minLength.toString()}}
|
{{'policyInEffectMinLength' | i18n : enforcedPolicyOptions?.minLength.toString()}}
|
||||||
|
|
|
@ -56,6 +56,23 @@ export class ChangePasswordComponent implements OnInit {
|
||||||
this.enforcedPolicyOptions = await this.policyService.getMasterPasswordPolicyOptions();
|
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() {
|
async submit() {
|
||||||
const hasEncKey = await this.cryptoService.hasEncKey();
|
const hasEncKey = await this.cryptoService.hasEncKey();
|
||||||
if (!hasEncKey) {
|
if (!hasEncKey) {
|
||||||
|
|
Loading…
Reference in New Issue