1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-22 03:03:43 +00:00

Admin config for master password policy (#463)

* Admin config for master password policy

* UI cleanup and master pass options improvements

* ui tweaks
This commit is contained in:
Kyle Spearrin
2020-02-19 21:25:46 -05:00
committed by GitHub
parent 6129fdb6e5
commit 83ba366558
4 changed files with 93 additions and 49 deletions

View File

@@ -10,9 +10,7 @@ import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
import { ApiService } from 'jslib/abstractions/api.service';
import { CollectionService } from 'jslib/abstractions/collection.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { PolicyType } from 'jslib/enums/policyType';
@@ -38,25 +36,27 @@ export class PolicyEditComponent implements OnInit {
// Master password
masterPassMinComplexity?: number;
masterPassMinLength?: number;
// TODO
masterPassRequireUpper?: number;
masterPassRequireLower?: number;
masterPassRequireNumbers?: number;
masterPassRequireSpecial?: number;
// Password generator
passGenMinLength?: number;
passGenMinNumbers?: number;
passGenMinSpecial?: number;
passGenUseNumbers?: boolean;
passGenUseSpecial?: boolean;
passGenUseUpper?: boolean;
passGenUseLower?: boolean;
passGenUseNumbers?: boolean;
passGenUseSpecial?: boolean;
passGenMinNumbers?: number;
passGenMinSpecial?: number;
private policy: PolicyResponse;
constructor(private apiService: ApiService, private i18nService: I18nService,
private analytics: Angulartics2, private toasterService: ToasterService,
private collectionService: CollectionService, private platformUtilsService: PlatformUtilsService) { }
private analytics: Angulartics2, private toasterService: ToasterService) { }
async ngOnInit() {
await this.load();
@@ -73,15 +73,20 @@ export class PolicyEditComponent implements OnInit {
switch (this.type) {
case PolicyType.PasswordGenerator:
this.passGenMinLength = this.policy.data.minLength;
this.passGenUseUpper = this.policy.data.useUpper;
this.passGenUseLower = this.policy.data.useLower;
this.passGenUseNumbers = this.policy.data.useNumbers;
this.passGenUseSpecial = this.policy.data.useSpecial;
this.passGenMinNumbers = this.policy.data.minNumbers;
this.passGenMinSpecial = this.policy.data.minSpecial;
this.passGenUseLower = this.policy.data.useLower;
this.passGenUseUpper = this.policy.data.useUpper;
this.passGenUseSpecial = this.policy.data.useSpecial;
this.passGenUseNumbers = this.policy.data.useNumbers;
break;
case PolicyType.MasterPassword:
this.masterPassMinComplexity = this.policy.data.minComplexity;
this.masterPassMinLength = this.policy.data.minLength;
this.masterPassRequireUpper = this.policy.data.requireUpper;
this.masterPassRequireLower = this.policy.data.requireLower;
this.masterPassRequireNumbers = this.policy.data.requireNumbers;
this.masterPassRequireSpecial = this.policy.data.requireSpecial;
break;
default:
break;
@@ -105,18 +110,23 @@ export class PolicyEditComponent implements OnInit {
switch (this.type) {
case PolicyType.PasswordGenerator:
request.data = {
minLength: this.passGenMinLength,
minNumbers: this.passGenMinNumbers,
minSpecial: this.passGenMinSpecial,
minLength: this.passGenMinLength || null,
useUpper: this.passGenUseUpper,
useLower: this.passGenUseLower,
useNumbers: this.passGenUseNumbers,
useSpecial: this.passGenUseSpecial,
useLower: this.passGenUseLower,
useUpper: this.passGenUseUpper,
minNumbers: this.passGenMinNumbers || null,
minSpecial: this.passGenMinSpecial || null,
};
break;
case PolicyType.MasterPassword:
request.data = {
minLength: this.masterPassMinLength,
minComplexity: this.masterPassMinComplexity || null,
minLength: this.masterPassMinLength || null,
requireUpper: this.masterPassRequireUpper,
requireLower: this.masterPassRequireLower,
requireNumbers: this.masterPassRequireNumbers,
requireSpecial: this.masterPassRequireSpecial,
};
break;
default: