1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

Integration with Have I been pwned (#47)

* Add password check.

* Fix indention, update messages.
This commit is contained in:
Oscar Hinton
2018-02-28 16:53:18 +01:00
committed by Kyle Spearrin
parent 06a543c913
commit df9d79ab7d
4 changed files with 39 additions and 1 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';
@@ -60,7 +61,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 },
@@ -212,6 +214,19 @@ export class AddEditComponent implements OnChanges {
document.getElementById('loginPassword').focus();
}
async checkPassword() {
this.analytics.eventTrack.next({ action: 'Check Password' });
const match = await this.auditService.passwordLeaked(this.cipher.login.password);
if (match > 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;