pass gen fixes. word sep option
This commit is contained in:
parent
d5f86747bf
commit
a867c14b2a
|
@ -17,7 +17,6 @@ export class PasswordGeneratorComponent implements OnInit {
|
||||||
password: string = '-';
|
password: string = '-';
|
||||||
showOptions = false;
|
showOptions = false;
|
||||||
avoidAmbiguous = false;
|
avoidAmbiguous = false;
|
||||||
type = '0';
|
|
||||||
|
|
||||||
constructor(protected passwordGenerationService: PasswordGenerationService,
|
constructor(protected passwordGenerationService: PasswordGenerationService,
|
||||||
protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService,
|
protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService,
|
||||||
|
@ -26,7 +25,7 @@ export class PasswordGeneratorComponent implements OnInit {
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.options = await this.passwordGenerationService.getOptions();
|
this.options = await this.passwordGenerationService.getOptions();
|
||||||
this.avoidAmbiguous = !this.options.ambiguous;
|
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.password = await this.passwordGenerationService.generatePassword(this.options);
|
||||||
this.platformUtilsService.eventTrack('Generated Password');
|
this.platformUtilsService.eventTrack('Generated Password');
|
||||||
await this.passwordGenerationService.addHistory(this.password);
|
await this.passwordGenerationService.addHistory(this.password);
|
||||||
|
@ -79,13 +78,14 @@ export class PasswordGeneratorComponent implements OnInit {
|
||||||
this.options.minLowercase = 0;
|
this.options.minLowercase = 0;
|
||||||
this.options.minUppercase = 0;
|
this.options.minUppercase = 0;
|
||||||
this.options.ambiguous = !this.avoidAmbiguous;
|
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) {
|
if (!this.options.uppercase && !this.options.lowercase && !this.options.number && !this.options.special) {
|
||||||
this.options.lowercase = true;
|
this.options.lowercase = true;
|
||||||
const lowercase = document.querySelector('#lowercase') as HTMLInputElement;
|
if (this.win != null) {
|
||||||
if (lowercase) {
|
const lowercase = this.win.document.querySelector('#lowercase') as HTMLInputElement;
|
||||||
lowercase.checked = true;
|
if (lowercase) {
|
||||||
|
lowercase.checked = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,5 +120,9 @@ export class PasswordGeneratorComponent implements OnInit {
|
||||||
} else if (this.options.numWords > 20) {
|
} else if (this.options.numWords > 20) {
|
||||||
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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ const DefaultOptions = {
|
||||||
minLowercase: 0,
|
minLowercase: 0,
|
||||||
special: false,
|
special: false,
|
||||||
minSpecial: 1,
|
minSpecial: 1,
|
||||||
type: 0,
|
type: 'password',
|
||||||
numWords: 3,
|
numWords: 3,
|
||||||
wordSeparator: ' ',
|
wordSeparator: '-',
|
||||||
};
|
};
|
||||||
|
|
||||||
const Keys = {
|
const Keys = {
|
||||||
|
@ -42,7 +42,7 @@ export class PasswordGenerationService implements PasswordGenerationServiceAbstr
|
||||||
// overload defaults with given options
|
// overload defaults with given options
|
||||||
const o = Object.assign({}, DefaultOptions, options);
|
const o = Object.assign({}, DefaultOptions, options);
|
||||||
|
|
||||||
if (o.type === 1) { // TODO: enum?
|
if (o.type === 'passphrase') {
|
||||||
return this.generatePassphrase(options);
|
return this.generatePassphrase(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ export class PasswordGenerationService implements PasswordGenerationServiceAbstr
|
||||||
o.numWords = DefaultOptions.numWords;
|
o.numWords = DefaultOptions.numWords;
|
||||||
}
|
}
|
||||||
if (o.wordSeparator == null || o.wordSeparator.length === 0 || o.wordSeparator.length > 1) {
|
if (o.wordSeparator == null || o.wordSeparator.length === 0 || o.wordSeparator.length > 1) {
|
||||||
o.wordSeparator = DefaultOptions.wordSeparator;
|
o.wordSeparator = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
const listLength = EEFLongWordList.length - 1;
|
const listLength = EEFLongWordList.length - 1;
|
||||||
|
|
Loading…
Reference in New Issue