1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

getPasswordStrengthUserInput

This commit is contained in:
Kyle Spearrin 2018-11-12 23:22:37 -05:00
parent aa16fb2a9e
commit c297728967

View File

@ -59,7 +59,8 @@ export class RegisterComponent {
return; return;
} }
const strengthResult = this.passwordGenerationService.passwordStrength(this.masterPassword, null); const strengthResult = this.passwordGenerationService.passwordStrength(this.masterPassword,
this.getPasswordStrengthUserInput());
if (strengthResult != null && strengthResult.score < 3) { if (strengthResult != null && strengthResult.score < 3) {
const result = await this.platformUtilsService.showDialog(this.i18nService.t('weakMasterPasswordDesc'), const result = await this.platformUtilsService.showDialog(this.i18nService.t('weakMasterPasswordDesc'),
this.i18nService.t('weakMasterPassword'), this.i18nService.t('yes'), this.i18nService.t('no'), this.i18nService.t('weakMasterPassword'), this.i18nService.t('yes'), this.i18nService.t('no'),
@ -69,8 +70,6 @@ export class RegisterComponent {
} }
} }
this.name = this.name === '' ? null : this.name;
this.email = this.email.trim().toLowerCase();
const kdf = KdfType.PBKDF2_SHA256; const kdf = KdfType.PBKDF2_SHA256;
const useLowerKdf = this.platformUtilsService.isEdge() || this.platformUtilsService.isIE(); const useLowerKdf = this.platformUtilsService.isEdge() || this.platformUtilsService.isIE();
const kdfIterations = useLowerKdf ? 10000 : 100000; const kdfIterations = useLowerKdf ? 10000 : 100000;
@ -107,8 +106,21 @@ export class RegisterComponent {
clearTimeout(this.masterPasswordStrengthTimeout); clearTimeout(this.masterPasswordStrengthTimeout);
} }
this.masterPasswordStrengthTimeout = setTimeout(() => { this.masterPasswordStrengthTimeout = setTimeout(() => {
const strengthResult = this.passwordGenerationService.passwordStrength(this.masterPassword, null); const strengthResult = this.passwordGenerationService.passwordStrength(this.masterPassword,
this.getPasswordStrengthUserInput());
this.masterPasswordScore = strengthResult == null ? null : strengthResult.score; this.masterPasswordScore = strengthResult == null ? null : strengthResult.score;
}, 300); }, 300);
} }
private getPasswordStrengthUserInput() {
let userInput: string[] = [];
const atPosition = this.email.indexOf('@');
if (atPosition > -1) {
userInput = userInput.concat(this.email.substr(0, atPosition).trim().toLowerCase().split(/[^A-Za-z0-9]/));
}
if (this.name != null && this.name !== '') {
userInput = userInput.concat(this.name.trim().toLowerCase().split(' '));
}
return userInput;
}
} }