1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 17:23:37 +00:00

convert methods to promises

This commit is contained in:
Kyle Spearrin
2017-11-02 08:54:40 -04:00
parent 54a909ab24
commit c3704c3dfd
7 changed files with 86 additions and 89 deletions

View File

@@ -1,4 +1,4 @@
angular
angular
.module('bit.lock')
.controller('lockController', function ($scope, $state, $analytics, i18nService, cryptoService, toastr,
@@ -26,18 +26,18 @@
$scope.submit = function () {
userService.getEmail(function (email) {
var key = cryptoService.makeKey($scope.masterPassword, email);
cryptoService.hashPassword($scope.masterPassword, key, function (keyHash) {
cryptoService.getKeyHash(function (storedKeyHash) {
if (storedKeyHash && keyHash && storedKeyHash === keyHash) {
cryptoService.setKey(key).then(function () {
chrome.runtime.sendMessage({ command: 'unlocked' });
$state.go('tabs.current');
});
}
else {
toastr.error(i18nService.invalidMasterPassword, i18nService.errorsOccurred);
}
});
cryptoService.hashPassword($scope.masterPassword, key).then(function (keyHash) {
return cryptoService.getKeyHash();
}).then(function (storedKeyHash) {
if (storedKeyHash && keyHash && storedKeyHash === keyHash) {
cryptoService.setKey(key).then(function () {
chrome.runtime.sendMessage({ command: 'unlocked' });
$state.go('tabs.current');
});
}
else {
toastr.error(i18nService.invalidMasterPassword, i18nService.errorsOccurred);
}
});
});
};