mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 17:23:37 +00:00
update key and verify email notification
This commit is contained in:
37
src/app/settings/settingsUpdateKeyController.js
Normal file
37
src/app/settings/settingsUpdateKeyController.js
Normal file
@@ -0,0 +1,37 @@
|
||||
angular
|
||||
.module('bit.settings')
|
||||
|
||||
.controller('settingsUpdateKeyController', function ($scope, $state, apiService, $uibModalInstance,
|
||||
cryptoService, authService, cipherService, validationService, toastr, $analytics) {
|
||||
$analytics.eventTrack('settingsUpdateKeyController', { category: 'Modal' });
|
||||
|
||||
$scope.save = function (form) {
|
||||
var encKey = cryptoService.getEncKey();
|
||||
if (encKey) {
|
||||
validationService.addError(form, 'MasterPasswordHash',
|
||||
'You do not need to update. You are already using the new encryption key.', true);
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.processing = true;
|
||||
var mpHash = cryptoService.hashPassword($scope.masterPassword);
|
||||
$scope.savePromise = cipherService.updateKey(mpHash, function () {
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
authService.logOut();
|
||||
$analytics.eventTrack('Key Updated');
|
||||
return $state.go('frontend.login.info');
|
||||
}).then(function () {
|
||||
toastr.success('Please log back in. If you are using other bitwarden applications, ' +
|
||||
'log out and back in to those as well.', 'Key Updated', { timeOut: 10000 });
|
||||
}, processError);
|
||||
};
|
||||
|
||||
function processError() {
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
toastr.error('Something went wrong.', 'Oh No!');
|
||||
}
|
||||
|
||||
$scope.close = function () {
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user