mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-26 17:08:33 +01:00
Enforce Password Generator Policy Options (#469)
* Initial commit for enforcing password generator policy options * Revert to previous isDev URL setup
This commit is contained in:
parent
5ed830205d
commit
a27eddae56
@ -59,19 +59,19 @@
|
||||
<div class="col-6 form-group">
|
||||
<label for="passGenMinLength">{{'minLength' | i18n}}</label>
|
||||
<input id="passGenMinLength" class="form-control" type="number" name="PassGenMinLength"
|
||||
[(ngModel)]="passGenMinLength">
|
||||
min="5" max="128" [(ngModel)]="passGenMinLength">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 form-group">
|
||||
<label for="passGenMinNumbers">{{'minNumbers' | i18n}}</label>
|
||||
<input id="passGenMinNumbers" class="form-control" type="number" name="PassGenMinNumbers"
|
||||
[(ngModel)]="passGenMinNumbers">
|
||||
min="0" max="9" [(ngModel)]="passGenMinNumbers">
|
||||
</div>
|
||||
<div class="col-6 form-group">
|
||||
<label for="passGenMinSpecial">{{'minSpecial' | i18n}}</label>
|
||||
<input id="passGenMinSpecial" class="form-control" type="number" name="PassGenMinSpecial"
|
||||
[(ngModel)]="passGenMinSpecial">
|
||||
min="0" max="9" [(ngModel)]="passGenMinSpecial">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
|
@ -113,7 +113,7 @@ const lockService = new LockService(cipherService, folderService, collectionServ
|
||||
const syncService = new SyncService(userService, apiService, settingsService,
|
||||
folderService, cipherService, cryptoService, collectionService, storageService, messagingService, policyService,
|
||||
async (expired: boolean) => messagingService.send('logout', { expired: expired }));
|
||||
const passwordGenerationService = new PasswordGenerationService(cryptoService, storageService);
|
||||
const passwordGenerationService = new PasswordGenerationService(cryptoService, storageService, policyService);
|
||||
const totpService = new TotpService(storageService, cryptoFunctionService);
|
||||
const containerService = new ContainerService(cryptoService);
|
||||
const authService = new AuthService(cryptoService, apiService,
|
||||
|
@ -53,34 +53,34 @@
|
||||
</div>
|
||||
<div class="form-group col-4">
|
||||
<label for="min-number">{{'minNumbers' | i18n}}</label>
|
||||
<input id="min-number" class="form-control" type="number" min="0" max="9" (input)="saveOptions()"
|
||||
[(ngModel)]="options.minNumber">
|
||||
<input id="min-number" class="form-control" type="number" min="0" max="9" (blur)="saveOptions()"
|
||||
[(ngModel)]="options.minNumber" (change)="minNumberChanged()">
|
||||
</div>
|
||||
<div class="form-group col-4">
|
||||
<label for="min-special">{{'minSpecial' | i18n}}</label>
|
||||
<input id="min-special" class="form-control" type="number" min="0" max="9" (input)="saveOptions()"
|
||||
[(ngModel)]="options.minSpecial">
|
||||
<input id="min-special" class="form-control" type="number" min="0" max="9" (blur)="saveOptions()"
|
||||
[(ngModel)]="options.minSpecial" (change)="minSpecialChanged()">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-check">
|
||||
<input id="uppercase" class="form-check-input" type="checkbox" (change)="saveOptions()"
|
||||
[(ngModel)]="options.uppercase">
|
||||
[(ngModel)]="options.uppercase" [disabled]="enforcedPolicyOptions?.useUppercase">
|
||||
<label for="uppercase" class="form-check-label">A-Z</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input id="lowercase" class="form-check-input" type="checkbox" (change)="saveOptions()"
|
||||
[(ngModel)]="options.lowercase">
|
||||
[(ngModel)]="options.lowercase" [disabled]="enforcedPolicyOptions?.useLowercase">
|
||||
<label for="lowercase" class="form-check-label">a-z</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input id="numbers" class="form-check-input" type="checkbox" (change)="saveOptions()"
|
||||
[(ngModel)]="options.number">
|
||||
[(ngModel)]="options.number" [disabled]="enforcedPolicyOptions?.useNumbers">
|
||||
<label for="numbers" class="form-check-label">0-9</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input id="special" class="form-check-input" type="checkbox" (change)="saveOptions()"
|
||||
[(ngModel)]="options.special">
|
||||
[(ngModel)]="options.special" [disabled]="enforcedPolicyOptions?.useSpecial">
|
||||
<label for="special" class="form-check-label">!@#$%^&*</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
|
@ -47,4 +47,12 @@ export class PasswordGeneratorComponent extends BasePasswordGeneratorComponent {
|
||||
lengthChanged() {
|
||||
document.getElementById('length').focus();
|
||||
}
|
||||
|
||||
minNumberChanged() {
|
||||
document.getElementById('min-number').focus();
|
||||
}
|
||||
|
||||
minSpecialChanged() {
|
||||
document.getElementById('min-special').focus();
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ export class AddEditComponent extends BaseAddEditComponent {
|
||||
async generatePassword(): Promise<boolean> {
|
||||
const confirmed = await super.generatePassword();
|
||||
if (confirmed) {
|
||||
const options = await this.passwordGenerationService.getOptions();
|
||||
const options = (await this.passwordGenerationService.getOptions())[0];
|
||||
this.cipher.login.password = await this.passwordGenerationService.generatePassword(options);
|
||||
}
|
||||
return confirmed;
|
||||
|
Loading…
Reference in New Issue
Block a user