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

add password check back to add/edit as well

This commit is contained in:
Kyle Spearrin 2018-02-28 11:55:00 -05:00
parent 093071c8f3
commit 0e993285ab
3 changed files with 27 additions and 2 deletions

View File

@ -35,6 +35,12 @@
[(ngModel)]="cipher.login.password"> [(ngModel)]="cipher.login.password">
</div> </div>
<div class="action-buttons"> <div class="action-buttons">
<button type="button" #checkPasswordBtn class="row-btn btn" appBlurClick
title="{{'checkPassword' | i18n}}" (click)="checkPassword()"
[appApiAction]="checkPasswordPromise" [disabled]="checkPasswordBtn.loading">
<i class="fa fa-lg fa-check-circle" [hidden]="checkPasswordBtn.loading"></i>
<i class="fa fa-lg fa-spinner fa-spin" [hidden]="!checkPasswordBtn.loading"></i>
</button>
<a class="row-btn" href="#" appStopClick appBlurClick <a class="row-btn" href="#" appStopClick appBlurClick
title="{{'toggleVisibility' | i18n}}" (click)="togglePassword()"> title="{{'toggleVisibility' | i18n}}" (click)="togglePassword()">
<i class="fa fa-lg" <i class="fa fa-lg"

View File

@ -15,6 +15,7 @@ import { CipherType } from 'jslib/enums/cipherType';
import { FieldType } from 'jslib/enums/fieldType'; import { FieldType } from 'jslib/enums/fieldType';
import { SecureNoteType } from 'jslib/enums/secureNoteType'; import { SecureNoteType } from 'jslib/enums/secureNoteType';
import { AuditService } from 'jslib/abstractions/audit.service';
import { CipherService } from 'jslib/abstractions/cipher.service'; import { CipherService } from 'jslib/abstractions/cipher.service';
import { FolderService } from 'jslib/abstractions/folder.service'; import { FolderService } from 'jslib/abstractions/folder.service';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
@ -48,6 +49,7 @@ export class AddEditComponent implements OnChanges {
title: string; title: string;
formPromise: Promise<any>; formPromise: Promise<any>;
deletePromise: Promise<any>; deletePromise: Promise<any>;
checkPasswordPromise: Promise<number>;
showPassword: boolean = false; showPassword: boolean = false;
cipherType = CipherType; cipherType = CipherType;
fieldType = FieldType; fieldType = FieldType;
@ -60,7 +62,8 @@ export class AddEditComponent implements OnChanges {
constructor(private cipherService: CipherService, private folderService: FolderService, constructor(private cipherService: CipherService, private folderService: FolderService,
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService, private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
private analytics: Angulartics2, private toasterService: ToasterService) { private analytics: Angulartics2, private toasterService: ToasterService,
private auditService: AuditService) {
this.typeOptions = [ this.typeOptions = [
{ name: i18nService.t('typeLogin'), value: CipherType.Login }, { name: i18nService.t('typeLogin'), value: CipherType.Login },
{ name: i18nService.t('typeCard'), value: CipherType.Card }, { name: i18nService.t('typeCard'), value: CipherType.Card },
@ -216,4 +219,20 @@ export class AddEditComponent implements OnChanges {
const f = (field as any); const f = (field as any);
f.showValue = !f.showValue; f.showValue = !f.showValue;
} }
async checkPassword() {
if (this.cipher.login == null || this.cipher.login.password == null || this.cipher.login.password === '') {
return;
}
this.analytics.eventTrack.next({ action: 'Check Password' });
this.checkPasswordPromise = this.auditService.passwordLeaked(this.cipher.login.password);
const matches = await this.checkPasswordPromise;
if (matches > 0) {
this.toasterService.popAsync('warning', null, this.i18nService.t('passwordExposed', matches.toString()));
} else {
this.toasterService.popAsync('success', null, this.i18nService.t('passwordSafe'));
}
}
} }

View File

@ -959,7 +959,7 @@
"message": "Window" "message": "Window"
}, },
"checkPassword": { "checkPassword": {
"message": "Check if this password has been exposed." "message": "Check if password has been exposed."
}, },
"passwordExposed": { "passwordExposed": {
"message": "This password has been exposed $VALUE$ time(s) in data breaches. You should change it.", "message": "This password has been exposed $VALUE$ time(s) in data breaches. You should change it.",