1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 09:13:33 +00:00

pass gen fixes. word sep option

This commit is contained in:
Kyle Spearrin
2018-10-08 22:06:06 -04:00
parent d5f86747bf
commit a867c14b2a
2 changed files with 14 additions and 10 deletions

View File

@@ -17,7 +17,6 @@ export class PasswordGeneratorComponent implements OnInit {
password: string = '-';
showOptions = false;
avoidAmbiguous = false;
type = '0';
constructor(protected passwordGenerationService: PasswordGenerationService,
protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService,
@@ -26,7 +25,7 @@ export class PasswordGeneratorComponent implements OnInit {
async ngOnInit() {
this.options = await this.passwordGenerationService.getOptions();
this.avoidAmbiguous = !this.options.ambiguous;
this.type = this.options.type === 1 ? '1' : '0';
this.options.type = this.options.type === 'passphrase' ? 'passphrase' : 'password';
this.password = await this.passwordGenerationService.generatePassword(this.options);
this.platformUtilsService.eventTrack('Generated Password');
await this.passwordGenerationService.addHistory(this.password);
@@ -79,13 +78,14 @@ export class PasswordGeneratorComponent implements OnInit {
this.options.minLowercase = 0;
this.options.minUppercase = 0;
this.options.ambiguous = !this.avoidAmbiguous;
this.options.type = this.type == null || this.type === '0' ? 0 : 1;
if (!this.options.uppercase && !this.options.lowercase && !this.options.number && !this.options.special) {
this.options.lowercase = true;
const lowercase = document.querySelector('#lowercase') as HTMLInputElement;
if (lowercase) {
lowercase.checked = true;
if (this.win != null) {
const lowercase = this.win.document.querySelector('#lowercase') as HTMLInputElement;
if (lowercase) {
lowercase.checked = true;
}
}
}
@@ -120,5 +120,9 @@ export class PasswordGeneratorComponent implements OnInit {
} else if (this.options.numWords > 20) {
this.options.numWords = 20;
}
if (this.options.wordSeparator != null && this.options.wordSeparator.length > 1) {
this.options.wordSeparator = this.options.wordSeparator[0];
}
}
}