From df9d79ab7d843ada9114d8f0aa2ae4f62ccb4ed4 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Wed, 28 Feb 2018 16:53:18 +0100 Subject: [PATCH] Integration with Have I been pwned (#47) * Add password check. * Fix indention, update messages. --- src/app/services/services.module.ts | 4 ++++ src/app/vault/add-edit.component.html | 4 ++++ src/app/vault/add-edit.component.ts | 17 ++++++++++++++++- src/locales/en/messages.json | 15 +++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index 4ba895e86d..e8fdb7cd05 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -22,6 +22,7 @@ import { Analytics } from 'jslib/misc/analytics'; import { ApiService } from 'jslib/services/api.service'; import { AppIdService } from 'jslib/services/appId.service'; +import { AuditService } from 'jslib/services/audit.service'; import { AuthService } from 'jslib/services/auth.service'; import { CipherService } from 'jslib/services/cipher.service'; import { CollectionService } from 'jslib/services/collection.service'; @@ -42,6 +43,7 @@ import { UtilsService } from 'jslib/services/utils.service'; import { ApiService as ApiServiceAbstraction } from 'jslib/abstractions/api.service'; import { AppIdService as AppIdServiceAbstraction } from 'jslib/abstractions/appId.service'; +import { AuditService as AuditServiceAbstraction } from 'jslib/abstractions/audit.service'; import { AuthService as AuthServiceAbstraction } from 'jslib/abstractions/auth.service'; import { CipherService as CipherServiceAbstraction } from 'jslib/abstractions/cipher.service'; import { CollectionService as CollectionServiceAbstraction } from 'jslib/abstractions/collection.service'; @@ -99,6 +101,7 @@ const containerService = new ContainerService(cryptoService, platformUtilsServic const authService = new AuthService(cryptoService, apiService, userService, tokenService, appIdService, i18nService, platformUtilsService, constantsService, messagingService); +const auditService = new AuditService(cryptoService); const analytics = new Analytics(window, () => isDev(), platformUtilsService, storageService, appIdService); containerService.attachToWindow(window); @@ -143,6 +146,7 @@ function initFactory(): Function { providers: [ ValidationService, AuthGuardService, + { provide: AuditServiceAbstraction, useValue: auditService }, { provide: AuthServiceAbstraction, useValue: authService }, { provide: CipherServiceAbstraction, useValue: cipherService }, { provide: FolderServiceAbstraction, useValue: folderService }, diff --git a/src/app/vault/add-edit.component.html b/src/app/vault/add-edit.component.html index 445d849785..10a0540545 100644 --- a/src/app/vault/add-edit.component.html +++ b/src/app/vault/add-edit.component.html @@ -35,6 +35,10 @@ [(ngModel)]="cipher.login.password">
+ + + 0) { + this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'), + this.i18nService.t('passwordExposed', match.toString())); + } else { + this.toasterService.popAsync('success', null, this.i18nService.t('passwordSafe')); + } + } + toggleFieldValue(field: FieldView) { const f = (field as any); f.showValue = !f.showValue; diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 75c870be31..7e5b11d2b6 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -957,5 +957,20 @@ }, "window": { "message": "Window" + }, + "checkPassword": { + "message": "Check if this password has been previously exposed." + }, + "passwordExposed": { + "message": "This password has been exposed in $VALUE$ data breach(es)! You should change it.", + "placeholders": { + "value": { + "content": "$1", + "example": "1" + } + } + }, + "passwordSafe": { + "message": "This password was not found in any known data breaches. It should be safe to use." } }