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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user