1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00: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

@@ -15,6 +15,7 @@ import { CipherType } from 'jslib/enums/cipherType';
import { FieldType } from 'jslib/enums/fieldType';
import { SecureNoteType } from 'jslib/enums/secureNoteType';
import { AuditService } from 'jslib/abstractions/audit.service';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { FolderService } from 'jslib/abstractions/folder.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
@@ -48,6 +49,7 @@ export class AddEditComponent implements OnChanges {
title: string;
formPromise: Promise<any>;
deletePromise: Promise<any>;
checkPasswordPromise: Promise<number>;
showPassword: boolean = false;
cipherType = CipherType;
fieldType = FieldType;
@@ -60,7 +62,8 @@ export class AddEditComponent implements OnChanges {
constructor(private cipherService: CipherService, private folderService: FolderService,
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
private analytics: Angulartics2, private toasterService: ToasterService) {
private analytics: Angulartics2, private toasterService: ToasterService,
private auditService: AuditService) {
this.typeOptions = [
{ name: i18nService.t('typeLogin'), value: CipherType.Login },
{ name: i18nService.t('typeCard'), value: CipherType.Card },
@@ -216,4 +219,20 @@ export class AddEditComponent implements OnChanges {
const f = (field as any);
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'));
}
}
}