diff --git a/src/app/services/apiService.js b/src/app/services/apiService.js index d87dea536c..86944cd406 100644 --- a/src/app/services/apiService.js +++ b/src/app/services/apiService.js @@ -35,6 +35,7 @@ delAdmin: { url: _apiUri + '/ciphers/:id/delete-admin', method: 'POST', params: { id: '@id' } }, delMany: { url: _apiUri + '/ciphers/delete', method: 'POST' }, moveMany: { url: _apiUri + '/ciphers/move', method: 'POST' }, + purge: { url: _apiUri + '/ciphers/purge', method: 'POST' }, postAttachment: { url: _apiUri + '/ciphers/:id/attachment', method: 'POST', diff --git a/src/app/settings/settingsController.js b/src/app/settings/settingsController.js index 4721587fe9..f31cc37d76 100644 --- a/src/app/settings/settingsController.js +++ b/src/app/settings/settingsController.js @@ -129,6 +129,14 @@ }); }; + $scope.purge = function () { + $uibModal.open({ + animation: true, + templateUrl: 'app/settings/views/settingsPurge.html', + controller: 'settingsPurgeController' + }); + }; + function scrollToTop() { $('html, body').animate({ scrollTop: 0 }, 200); } diff --git a/src/app/settings/settingsPurgeController.js b/src/app/settings/settingsPurgeController.js new file mode 100644 index 0000000000..74859d784e --- /dev/null +++ b/src/app/settings/settingsPurgeController.js @@ -0,0 +1,24 @@ +angular + .module('bit.settings') + + .controller('settingsPurgeController', function ($scope, $state, apiService, $uibModalInstance, cryptoService, + authService, toastr, $analytics, tokenService) { + $analytics.eventTrack('settingsPurgeController', { category: 'Modal' }); + $scope.submit = function (model) { + $scope.submitPromise = cryptoService.hashPassword(model.masterPassword).then(function (hash) { + return apiService.ciphers.purge({ + masterPasswordHash: hash + }).$promise; + }).then(function () { + $uibModalInstance.dismiss('cancel'); + $analytics.eventTrack('Purged Vault'); + return $state.go('backend.user.vault', { refreshFromServer: true }); + }).then(function () { + toastr.success('All items in your vault have been deleted.', 'Vault Purged'); + }); + }; + + $scope.close = function () { + $uibModalInstance.dismiss('cancel'); + }; + }); diff --git a/src/app/settings/views/settings.html b/src/app/settings/views/settings.html index 3c78af8079..1b50ffb5a9 100644 --- a/src/app/settings/views/settings.html +++ b/src/app/settings/views/settings.html @@ -150,10 +150,13 @@ Careful, these actions are not reversible!
diff --git a/src/app/settings/views/settingsPurge.html b/src/app/settings/views/settingsPurge.html new file mode 100644 index 0000000000..b73d7738c0 --- /dev/null +++ b/src/app/settings/views/settingsPurge.html @@ -0,0 +1,33 @@ +