diff --git a/src/popup/app/lock/lock.component.html b/src/popup/app/lock/lock.component.html index dc23dda603..b8b4c14121 100644 --- a/src/popup/app/lock/lock.component.html +++ b/src/popup/app/lock/lock.component.html @@ -1,4 +1,4 @@ -
+
@@ -12,8 +12,8 @@
- +
diff --git a/src/popup/app/lock/lock.component.ts b/src/popup/app/lock/lock.component.ts index c8c1a9bd52..9661bcaaea 100644 --- a/src/popup/app/lock/lock.component.ts +++ b/src/popup/app/lock/lock.component.ts @@ -4,15 +4,16 @@ import { CryptoService } from '../../../services/abstractions/crypto.service'; class LockController { i18n: any; + masterPassword: string; - constructor(public $scope: any, public $state: any, public i18nService: any, - public cryptoService: CryptoService, public toastr: any, public userService: any, - public SweetAlert: any, public $timeout: any) { + constructor(public $state: any, public i18nService: any, + public cryptoService: CryptoService, public toastr: any, public userService: any, + public SweetAlert: any) { this.i18n = i18nService; + } - $timeout(() => { - document.getElementById('master-password').focus(); - }); + $onInit() { + document.getElementById('master-password').focus(); } logOut() { @@ -30,12 +31,17 @@ class LockController { } async submit() { + if (this.masterPassword == null || this.masterPassword === '') { + this.toastr.error(this.i18nService.invalidMasterPassword, this.i18nService.errorsOccurred); + return; + } + const email = await this.userService.getEmail(); - const key = this.cryptoService.makeKey(this.$scope.masterPassword, email); - const keyHash = await this.cryptoService.hashPassword(this.$scope.masterPassword, key); + const key = this.cryptoService.makeKey(this.masterPassword, email); + const keyHash = await this.cryptoService.hashPassword(this.masterPassword, key); const storedKeyHash = await this.cryptoService.getKeyHash(); - if (storedKeyHash && keyHash && storedKeyHash === keyHash) { + if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) { await this.cryptoService.setKey(key); chrome.runtime.sendMessage({ command: 'unlocked' }); this.$state.go('tabs.current'); diff --git a/src/popup/app/tools/export.component.html b/src/popup/app/tools/export.component.html index 62a6af853b..2dda413c53 100644 --- a/src/popup/app/tools/export.component.html +++ b/src/popup/app/tools/export.component.html @@ -1,4 +1,4 @@ - +
{{$ctrl.i18n.close}} diff --git a/src/popup/app/tools/export.component.ts b/src/popup/app/tools/export.component.ts index d100c73512..4663a3ba8f 100644 --- a/src/popup/app/tools/export.component.ts +++ b/src/popup/app/tools/export.component.ts @@ -11,28 +11,35 @@ export class ExportController { i18n: any; masterPassword: string; - constructor(private $scope: any, private $state: any, private cryptoService: CryptoService, + constructor(private $state: any, private cryptoService: CryptoService, private toastr: any, private utilsService: UtilsService, private $analytics: any, private i18nService: any, private folderService: any, private cipherService: any, private $window: any, private userService: any) { this.i18n = i18nService; - this.$scope.submitPromise = null; } $onInit() { document.getElementById('master-password').focus(); } - submit() { - const self = this; - this.$scope.submitPromise = this.checkPassword().then(() => { - return self.getCsv(); - }).then((csv) => { - self.$analytics.eventTrack('Exported Data'); - self.downloadFile(csv); - }, () => { - this.toastr.error(self.i18n.invalidMasterPassword, self.i18n.errorsOccurred); - }); + async submit() { + if (this.masterPassword == null || this.masterPassword === '') { + this.toastr.error(this.i18nService.invalidMasterPassword, this.i18nService.errorsOccurred); + return; + } + + const email = await this.userService.getEmail(); + const key = this.cryptoService.makeKey(this.masterPassword, email); + const keyHash = await this.cryptoService.hashPassword(this.masterPassword, key); + const storedKeyHash = await this.cryptoService.getKeyHash(); + + if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) { + const csv = await this.getCsv(); + this.$analytics.eventTrack('Exported Data'); + this.downloadFile(csv); + } else { + this.toastr.error(this.i18n.invalidMasterPassword, this.i18n.errorsOccurred); + } } private async checkPassword() {