getPasswordStrengthUserInput on password change
This commit is contained in:
parent
26d4fb8005
commit
912e1cf89f
2
jslib
2
jslib
|
@ -1 +1 @@
|
||||||
Subproject commit aa16fb2a9e4b6fb33ed80dea2a4c7bfa2234d45c
|
Subproject commit c297728967bc12d7d4444b171a7d1fd79b68ec7d
|
|
@ -1,5 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
|
OnInit,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
import { ToasterService } from 'angular2-toaster';
|
||||||
|
@ -19,7 +20,7 @@ import { PasswordRequest } from 'jslib/models/request/passwordRequest';
|
||||||
selector: 'app-change-password',
|
selector: 'app-change-password',
|
||||||
templateUrl: 'change-password.component.html',
|
templateUrl: 'change-password.component.html',
|
||||||
})
|
})
|
||||||
export class ChangePasswordComponent {
|
export class ChangePasswordComponent implements OnInit {
|
||||||
currentMasterPassword: string;
|
currentMasterPassword: string;
|
||||||
newMasterPassword: string;
|
newMasterPassword: string;
|
||||||
confirmNewMasterPassword: string;
|
confirmNewMasterPassword: string;
|
||||||
|
@ -27,6 +28,7 @@ export class ChangePasswordComponent {
|
||||||
masterPasswordScore: number;
|
masterPasswordScore: number;
|
||||||
|
|
||||||
private masterPasswordStrengthTimeout: any;
|
private masterPasswordStrengthTimeout: any;
|
||||||
|
private email: string;
|
||||||
|
|
||||||
constructor(private apiService: ApiService, private i18nService: I18nService,
|
constructor(private apiService: ApiService, private i18nService: I18nService,
|
||||||
private analytics: Angulartics2, private toasterService: ToasterService,
|
private analytics: Angulartics2, private toasterService: ToasterService,
|
||||||
|
@ -34,6 +36,10 @@ export class ChangePasswordComponent {
|
||||||
private userService: UserService, private passwordGenerationService: PasswordGenerationService,
|
private userService: UserService, private passwordGenerationService: PasswordGenerationService,
|
||||||
private platformUtilsService: PlatformUtilsService) { }
|
private platformUtilsService: PlatformUtilsService) { }
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
this.email = await this.userService.getEmail();
|
||||||
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
const hasEncKey = await this.cryptoService.hasEncKey();
|
const hasEncKey = await this.cryptoService.hasEncKey();
|
||||||
if (!hasEncKey) {
|
if (!hasEncKey) {
|
||||||
|
@ -58,7 +64,8 @@ export class ChangePasswordComponent {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const strengthResult = this.passwordGenerationService.passwordStrength(this.newMasterPassword, null);
|
const strengthResult = this.passwordGenerationService.passwordStrength(this.newMasterPassword,
|
||||||
|
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'),
|
||||||
|
@ -92,8 +99,18 @@ export class ChangePasswordComponent {
|
||||||
clearTimeout(this.masterPasswordStrengthTimeout);
|
clearTimeout(this.masterPasswordStrengthTimeout);
|
||||||
}
|
}
|
||||||
this.masterPasswordStrengthTimeout = setTimeout(() => {
|
this.masterPasswordStrengthTimeout = setTimeout(() => {
|
||||||
const strengthResult = this.passwordGenerationService.passwordStrength(this.newMasterPassword, null);
|
const strengthResult = this.passwordGenerationService.passwordStrength(this.newMasterPassword,
|
||||||
|
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]/));
|
||||||
|
}
|
||||||
|
return userInput;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue