Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
passphrase cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Oct 8, 2018
1 parent c4da05d commit d5f8674
Show file tree
Hide file tree
Showing 5 changed files with 7,802 additions and 7,790 deletions.
1 change: 1 addition & 0 deletions src/abstractions/passwordGeneration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { GeneratedPasswordHistory } from '../models/domain/generatedPasswordHist

export abstract class PasswordGenerationService {
generatePassword: (options: any) => Promise<string>;
generatePassphrase: (options: any) => Promise<string>;
getOptions: () => any;
saveOptions: (options: any) => Promise<any>;
getHistory: () => Promise<GeneratedPasswordHistory[]>;
Expand Down
13 changes: 6 additions & 7 deletions src/angular/components/password-generator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class PasswordGeneratorComponent implements OnInit {
password: string = '-';
showOptions = false;
avoidAmbiguous = false;
type = '0';

constructor(protected passwordGenerationService: PasswordGenerationService,
protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService,
Expand All @@ -25,6 +26,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.password = await this.passwordGenerationService.generatePassword(this.options);
this.platformUtilsService.eventTrack('Generated Password');
await this.passwordGenerationService.addHistory(this.password);
Expand Down Expand Up @@ -77,12 +79,7 @@ export class PasswordGeneratorComponent implements OnInit {
this.options.minLowercase = 0;
this.options.minUppercase = 0;
this.options.ambiguous = !this.avoidAmbiguous;

let typePassword = false;
if (!this.options.generateTypePassword || this.options.generateTypePassword === 'generate-password') {
typePassword = true;
}
this.options.generatePassphrase = !typePassword;
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;
Expand Down Expand Up @@ -118,8 +115,10 @@ export class PasswordGeneratorComponent implements OnInit {
this.options.minSpecial = this.options.length - this.options.minNumber;
}

if (!this.options.numWords || this.options.length < 3) {
if (this.options.numWords == null || this.options.length < 3) {
this.options.numWords = 3;
} else if (this.options.numWords > 20) {
this.options.numWords = 20;
}
}
}
Loading

0 comments on commit d5f8674

Please sign in to comment.