1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

Moved callout to jslib, made policyInEffect a prop (#77)

* Moved callout to jslib, made policyInEffect a prop

* remove true condition
This commit is contained in:
Kyle Spearrin
2020-02-28 16:57:34 -05:00
committed by GitHub
parent 6c52942204
commit fb48091bb8
3 changed files with 69 additions and 18 deletions

View File

@@ -19,6 +19,7 @@ export class PasswordGeneratorComponent implements OnInit {
password: string = '-';
showOptions = false;
avoidAmbiguous = false;
policyInEffect = false;
enforcedPolicyOptions: PasswordGeneratorPolicyOptions;
constructor(protected passwordGenerationService: PasswordGenerationService,
@@ -29,6 +30,14 @@ export class PasswordGeneratorComponent implements OnInit {
const optionsResponse = await this.passwordGenerationService.getOptions();
this.options = optionsResponse[0];
this.enforcedPolicyOptions = optionsResponse[1];
this.policyInEffect = this.enforcedPolicyOptions != null && (
this.enforcedPolicyOptions.minLength > 0 ||
this.enforcedPolicyOptions.numberCount > 0 ||
this.enforcedPolicyOptions.specialCount > 0 ||
this.enforcedPolicyOptions.useUppercase ||
this.enforcedPolicyOptions.useLowercase ||
this.enforcedPolicyOptions.useNumbers ||
this.enforcedPolicyOptions.useSpecial);
this.avoidAmbiguous = !this.options.ambiguous;
this.options.type = this.options.type === 'passphrase' ? 'passphrase' : 'password';
this.password = await this.passwordGenerationService.generatePassword(this.options);
@@ -79,24 +88,6 @@ export class PasswordGeneratorComponent implements OnInit {
this.showOptions = !this.showOptions;
}
hasPolicyInEffect() {
if (this.enforcedPolicyOptions == null) {
return false;
}
if (this.enforcedPolicyOptions.minLength > 0
|| this.enforcedPolicyOptions.numberCount > 0
|| this.enforcedPolicyOptions.specialCount > 0
|| this.enforcedPolicyOptions.useUppercase
|| this.enforcedPolicyOptions.useLowercase
|| this.enforcedPolicyOptions.useNumbers
|| this.enforcedPolicyOptions.useSpecial) {
return true;
} else {
return false;
}
}
private normalizeOptions() {
this.options.minLowercase = 0;
this.options.minUppercase = 0;