From f3eaf644b0931646c5188c886d0b224843a82c4c Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 25 Oct 2017 21:46:35 -0400 Subject: [PATCH] purge vault --- src/app/services/apiService.js | 1 + src/app/settings/settingsController.js | 8 +++++ src/app/settings/settingsPurgeController.js | 24 +++++++++++++++ src/app/settings/views/settings.html | 7 +++-- src/app/settings/views/settingsPurge.html | 33 +++++++++++++++++++++ src/index.html | 1 + 6 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/app/settings/settingsPurgeController.js create mode 100644 src/app/settings/views/settingsPurge.html 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 @@ + +
+ + +
diff --git a/src/index.html b/src/index.html index 41c770963a..33fe8abc5a 100644 --- a/src/index.html +++ b/src/index.html @@ -274,6 +274,7 @@ +