diff --git a/src/app/accounts/accountsRecoverDeleteController.js b/src/app/accounts/accountsRecoverDeleteController.js new file mode 100644 index 00000000..a6cc7bb5 --- /dev/null +++ b/src/app/accounts/accountsRecoverDeleteController.js @@ -0,0 +1,13 @@ +angular + .module('bit.accounts') + + .controller('accountsRecoverDeleteController', function ($scope, $rootScope, apiService, $analytics) { + $scope.success = false; + + $scope.submit = function (model) { + $scope.submitPromise = apiService.accounts.postDeleteRecover({ email: model.email }, function () { + $analytics.eventTrack('Started Delete Recovery'); + $scope.success = true; + }).$promise; + }; + }); diff --git a/src/app/accounts/accountsVerifyRecoverDeleteController.js b/src/app/accounts/accountsVerifyRecoverDeleteController.js new file mode 100644 index 00000000..e5a056e7 --- /dev/null +++ b/src/app/accounts/accountsVerifyRecoverDeleteController.js @@ -0,0 +1,36 @@ +angular + .module('bit.accounts') + + .controller('accountsVerifyRecoverDeleteController', function ($scope, $state, apiService, toastr, $analytics) { + if (!$state.params.userId || !$state.params.token || !$state.params.email) { + $state.go('frontend.login.info').then(function () { + toastr.error('Invalid parameters.'); + }); + return; + } + + $scope.email = $state.params.email; + + $scope.delete = function () { + if (!confirm('Are you sure you want to delete this account? This cannot be undone.')) { + return; + } + + $scope.deleting = true; + apiService.accounts.postDeleteRecoverToken({}, + { + token: $state.params.token, + userId: $state.params.userId + }, function () { + $analytics.eventTrack('Recovered Delete'); + $state.go('frontend.login.info', null, { location: 'replace' }).then(function () { + toastr.success('Your account has been deleted. You can register a new account again if you like.', + 'Success'); + }); + }, function () { + $state.go('frontend.login.info', null, { location: 'replace' }).then(function () { + toastr.error('Unable to delete account.', 'Error'); + }); + }); + }; + }); diff --git a/src/app/accounts/views/accountsRecoverDelete.html b/src/app/accounts/views/accountsRecoverDelete.html new file mode 100644 index 00000000..7e3ad4dc --- /dev/null +++ b/src/app/accounts/views/accountsRecoverDelete.html @@ -0,0 +1,39 @@ +
Enter your email address below to recover & delete your bitwarden account.
++ You have requested to delete your bitwarden account ({{email}}). + Click the button below to confirm and proceed. +
+ +