diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index ef7b64c9e5..36639d4553 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -980,5 +980,14 @@ }, "twoStepNewWindowMessage": { "message": "Complete your two-step login request using the new tab." + }, + "checkPassword": { + "message": "Check if the password have been previously exposed." + }, + "passwordExposed": { + "message": "This password have been previously exposed in data breaches!" + }, + "passwordSafe": { + "message": "This password was not found in a current data breach! It should be safe to use." } } diff --git a/src/popup/app/services/services.module.ts b/src/popup/app/services/services.module.ts index 04fbc06104..2662a58be9 100644 --- a/src/popup/app/services/services.module.ts +++ b/src/popup/app/services/services.module.ts @@ -4,6 +4,7 @@ import { PopupUtilsService } from './popupUtils.service'; import { StateService } from './state.service'; import { ValidationService } from './validation.service'; +import { AuditService } from 'jslib/services/audit.service'; import { AuthService } from 'jslib/services/auth.service'; import BrowserMessagingService from '../../../services/browserMessaging.service'; @@ -43,5 +44,6 @@ export default angular .factory('totpService', backgroundServices.totpService) .factory('environmentService', backgroundServices.environmentService) .factory('collectionService', backgroundServices.collectionService) + .factory('auditService', AuditService) .name; diff --git a/src/popup/app/vault/vaultAddCipherController.js b/src/popup/app/vault/vaultAddCipherController.js index 101c44d106..608f472ab3 100644 --- a/src/popup/app/vault/vaultAddCipherController.js +++ b/src/popup/app/vault/vaultAddCipherController.js @@ -2,7 +2,7 @@ angular .module('bit.vault') .controller('vaultAddCipherController', function ($scope, $state, $stateParams, cipherService, folderService, - cryptoService, toastr, popupUtilsService, $analytics, i18nService, constantsService, $timeout) { + cryptoService, toastr, popupUtilsService, $analytics, i18nService, constantsService, $timeout, auditService) { $scope.i18n = i18nService; $scope.constants = constantsService; $scope.addFieldType = constantsService.fieldType.text.toString(); @@ -94,6 +94,20 @@ angular $scope.showPassword = !$scope.showPassword; }; + $scope.checkPassword = () => { + $analytics.eventTrack('Check Password'); + + auditService + .passwordLeaked($scope.cipher.login.password) + .then((matches) => { + if (matches != 0) { + toastr.error(i18nService.passwordExposed, i18nService.errorsOccurred); + } else { + toastr.success(i18nService.passwordSafe) + } + }) + }; + $scope.addField = function (type) { if (!$scope.cipher.fields) { $scope.cipher.fields = []; diff --git a/src/popup/app/vault/vaultEditCipherController.js b/src/popup/app/vault/vaultEditCipherController.js index d9c4016aac..db41d72b5a 100644 --- a/src/popup/app/vault/vaultEditCipherController.js +++ b/src/popup/app/vault/vaultEditCipherController.js @@ -3,7 +3,7 @@ angular .controller('vaultEditCipherController', function ($scope, $state, $stateParams, cipherService, folderService, cryptoService, toastr, SweetAlert, platformUtilsService, $analytics, i18nService, constantsService, $timeout, - popupUtilsService) { + popupUtilsService, auditService) { $timeout(function () { popupUtilsService.initListSectionItemListeners(document, angular); document.getElementById('name').focus(); @@ -112,6 +112,20 @@ angular $scope.showPassword = !$scope.showPassword; }; + $scope.checkPassword = () => { + $analytics.eventTrack('Check Password'); + + auditService + .passwordLeaked($scope.cipher.login.password) + .then((matches) => { + if (matches != 0) { + toastr.error(i18nService.passwordExposed, i18nService.errorsOccurred); + } else { + toastr.success(i18nService.passwordSafe) + } + }) + }; + $scope.addField = function (type) { if (!$scope.cipher.fields) { $scope.cipher.fields = []; diff --git a/src/popup/app/vault/views/vaultAddCipher.html b/src/popup/app/vault/views/vaultAddCipher.html index b39fd02ccb..6aed1d396b 100644 --- a/src/popup/app/vault/views/vaultAddCipher.html +++ b/src/popup/app/vault/views/vaultAddCipher.html @@ -44,6 +44,9 @@
+ + + diff --git a/src/popup/app/vault/views/vaultEditCipher.html b/src/popup/app/vault/views/vaultEditCipher.html index 70c08f999e..8eacc8d3a6 100644 --- a/src/popup/app/vault/views/vaultEditCipher.html +++ b/src/popup/app/vault/views/vaultEditCipher.html @@ -37,6 +37,9 @@
+ + +