1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-21 16:18:28 +01:00

Added settings account delete

This commit is contained in:
Kyle Spearrin 2015-12-27 00:15:35 -05:00
parent 9aa62e748c
commit 0c32e890b3
9 changed files with 97 additions and 3 deletions

View File

@ -32,8 +32,9 @@
/// <reference path="app/settings/settingsChangeEmailController.js" />
/// <reference path="app/settings/settingsChangePasswordController.js" />
/// <reference path="app/settings/settingsController.js" />
/// <reference path="app/settings/settingsdeletecontroller.js" />
/// <reference path="app/settings/settingsmodule.js" />
/// <reference path="app/settings/settingssessioncontroller.js" />
/// <reference path="app/settings/settingsSessionsController.js" />
/// <reference path="app/settings/settingsTwoFactorController.js" />
/// <reference path="app/tools/toolsAuditsController.js" />
/// <reference path="app/tools/toolsController.js" />
@ -46,3 +47,24 @@
/// <reference path="app/vault/vaultEditFolderController.js" />
/// <reference path="app/vault/vaultEditSiteController.js" />
/// <reference path="app/vault/vaultmodule.js" />
/// <reference path="lib/admin-lte/js/app.js" />
/// <reference path="lib/angular/angular.js" />
/// <reference path="lib/angular-bootstrap/angular-bootstrap-tpls.js" />
/// <reference path="lib/angular-bootstrap-show-errors/showErrors.js" />
/// <reference path="lib/angular-cookies/angular-cookies.js" />
/// <reference path="lib/angular-jwt/angular-jwt.js" />
/// <reference path="lib/angular-md5/angular-md5.js" />
/// <reference path="lib/angular-messages/angular-messages.js" />
/// <reference path="lib/angular-resource/angular-resource.js" />
/// <reference path="lib/angular-toastr/angular-toastr.js" />
/// <reference path="lib/angular-toastr/angular-toastr.tpls.js" />
/// <reference path="lib/angular-ui-router/angular-ui-router.js" />
/// <reference path="lib/bootstrap/js/bootstrap.js" />
/// <reference path="lib/clipboard/clipboard.js" />
/// <reference path="lib/jquery/jquery.js" />
/// <reference path="lib/ngclipboard/ngclipboard.js" />
/// <reference path="lib/ngstorage/ngStorage.js" />
/// <reference path="lib/papaparse/papaparse.js" />
/// <reference path="lib/sjcl/bitArray.js" />
/// <reference path="lib/sjcl/cbc.js" />
/// <reference path="lib/sjcl/sjcl.js" />

View File

@ -60,6 +60,10 @@ angular
$scope.$broadcast('settingsSessions');
};
$scope.delete = function () {
$scope.$broadcast('settingsDelete');
};
$scope.twoFactor = function () {
$scope.$broadcast('settingsTwoFactor');
};

View File

@ -33,7 +33,8 @@
putTwoFactor: { url: _apiUri + '/accounts/two-factor', method: 'PUT', params: {} },
postPasswordHint: { url: _apiUri + '/accounts/password-hint', method: 'POST', params: {} },
putSecurityStamp: { url: _apiUri + '/accounts/security-stamp', method: 'PUT', params: {} },
'import': { url: _apiUri + '/accounts/import', method: 'POST', params: {} }
'import': { url: _apiUri + '/accounts/import', method: 'POST', params: {} },
postDelete: { url: _apiUri + '/accounts/delete', method: 'POST', params: {} }
});
_service.auth = $resource(_apiUri + '/auth', {}, {

View File

@ -69,4 +69,17 @@
$scope.$on('settingsSessions', function (event, args) {
$scope.sessions();
});
$scope.delete = function () {
$uibModal.open({
animation: true,
templateUrl: 'app/settings/views/settingsDelete.html',
controller: 'settingsDeleteController',
size: 'sm'
});
};
$scope.$on('settingsDelete', function (event, args) {
$scope.delete();
});
});

View File

@ -0,0 +1,22 @@
angular
.module('bit.settings')
.controller('settingsDeleteController', function ($scope, $state, apiService, $uibModalInstance, cryptoService, authService, toastr) {
$scope.submit = function (model) {
var request = {
masterPasswordHash: cryptoService.hashPassword(model.masterPassword)
};
$scope.submitPromise = apiService.accounts.postDelete(request, function () {
$uibModalInstance.dismiss('cancel');
authService.logOut();
$state.go('frontend.login.info').then(function () {
toastr.success('Your account has been closed and all associated data has been deleted.', 'Account Deleted');
});
}).$promise;
};
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
};
});

View File

@ -0,0 +1,30 @@
<div class="modal-header">
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="deleteAccountModelLabel"><i class="fa fa-ban"></i> Delete Account</h4>
</div>
<form name="deleteAccountForm" ng-submit="deleteAccountForm.$valid && submit(model)" api-form="submitPromise">
<div class="modal-body">
<p>Continue below to delete your account and all associated data.</p>
<div class="callout callout-warning">
<h4><i class="fa fa-warning"></i> Warning</h4>
Deleting your account is permanent. It cannot be undone.
</div>
<div class="callout callout-danger validation-errors" ng-show="deleteAccountForm.$errors">
<h4>Errors have occured</h4>
<ul>
<li ng-repeat="e in deleteAccountForm.$errors">{{e}}</li>
</ul>
</div>
<div class="form-group" show-errors>
<label for="masterPassword">Master Password</label>
<input type="password" id="masterPassword" name="MasterPasswordHash" ng-model="model.masterPassword" class="form-control"
required api-field />
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="deleteAccountForm.$loading">
<i class="fa fa-refresh fa-spin loading-icon" ng-show="deleteAccountForm.$loading"></i>Delete
</button>
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
</div>
</form>

View File

@ -77,7 +77,7 @@
};
function doImport(folders, sites, siteRelationships) {
$scope.importPromise = apiService.tools.import({
$scope.importPromise = apiService.accounts.import({
folders: cipherService.encryptFolders(folders, cryptoService.getKey()),
sites: cipherService.encryptSites(sites, cryptoService.getKey()),
siteRelationships: siteRelationships

View File

@ -52,6 +52,7 @@
<li><a href="javascript:void(0)" ng-click="changeEmail()"><i class="fa fa-circle-o"></i> Change Email</a></li>
<li><a href="javascript:void(0)" ng-click="sessions()"><i class="fa fa-circle-o"></i> Deauthorize Sessions</a></li>
<li><a href="javascript:void(0)" ng-click="twoFactor()"><i class="fa fa-circle-o"></i> Two-step Login</a></li>
<li><a href="javascript:void(0)" ng-click="delete()"><i class="fa fa-circle-o"></i> Delete Account</a></li>
</ul>
</li>
<li class="treeview" ng-class="{active: $state.includes('backend.tools')}">

View File

@ -113,6 +113,7 @@
<script src="app/settings/settingsChangeEmailController.js"></script>
<script src="app/settings/settingsTwoFactorController.js"></script>
<script src="app/settings/settingsSessionsController.js"></script>
<script src="app/settings/settingsDeleteController.js"></script>
<script src="app/tools/toolsModule.js"></script>
<script src="app/tools/toolsController.js"></script>