From 0e993285aba11e74e6ab83cb0e38fa4d75eb5029 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 28 Feb 2018 11:55:00 -0500 Subject: [PATCH] add password check back to add/edit as well --- src/app/vault/add-edit.component.html | 6 ++++++ src/app/vault/add-edit.component.ts | 21 ++++++++++++++++++++- src/locales/en/messages.json | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/app/vault/add-edit.component.html b/src/app/vault/add-edit.component.html index 445d849785..cdcbe62083 100644 --- a/src/app/vault/add-edit.component.html +++ b/src/app/vault/add-edit.component.html @@ -35,6 +35,12 @@ [(ngModel)]="cipher.login.password">
+ ; deletePromise: Promise; + checkPasswordPromise: Promise; 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')); + } + } } diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 5b1f69262f..79927f9bab 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -959,7 +959,7 @@ "message": "Window" }, "checkPassword": { - "message": "Check if this password has been exposed." + "message": "Check if password has been exposed." }, "passwordExposed": { "message": "This password has been exposed $VALUE$ time(s) in data breaches. You should change it.",