1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

delete organization

This commit is contained in:
Kyle Spearrin 2017-04-11 10:52:16 -04:00
parent cf22ea2b78
commit 5f028ea65f
7 changed files with 106 additions and 1 deletions

View File

@ -0,0 +1,26 @@
angular
.module('bit.organization')
.controller('organizationDeleteController', function ($scope, $state, apiService, $uibModalInstance, cryptoService,
authService, toastr, $analytics) {
$analytics.eventTrack('organizationDeleteController', { category: 'Modal' });
$scope.submit = function () {
var request = {
masterPasswordHash: cryptoService.hashPassword($scope.masterPassword)
};
$scope.submitPromise = apiService.organizations.del({ id: $state.params.orgId }, request, function () {
$uibModalInstance.dismiss('cancel');
authService.removeProfileOrganization($state.params.orgId);
$analytics.eventTrack('Deleted Organization');
$state.go('backend.user.vault').then(function () {
toastr.success('This organization and all associated data has been deleted.',
'Organization Deleted');
});
}).$promise;
};
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
};
});

View File

@ -1,7 +1,7 @@
angular
.module('bit.organization')
.controller('organizationSettingsController', function ($scope, $state, apiService, toastr, authService) {
.controller('organizationSettingsController', function ($scope, $state, apiService, toastr, authService, $uibModal) {
$scope.model = {};
$scope.$on('$viewContentLoaded', function () {
apiService.organizations.get({ id: $state.params.orgId }, function (org) {
@ -20,4 +20,12 @@
});
}).$promise;
};
$scope.delete = function () {
$uibModal.open({
animation: true,
templateUrl: 'app/organization/views/organizationDelete.html',
controller: 'organizationDeleteController'
});
};
});

View File

@ -0,0 +1,34 @@
<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"><i class="fa fa-trash"></i> Delete Organization</h4>
</div>
<form name="form" ng-submit="form.$valid && submit()" api-form="submitPromise">
<div class="modal-body">
<p>
Continue below to delete this organization and all associated data. This data includes any subvaults and
their associated logins. Individual user accounts will remain, though they will not be associated to this
organization anymore.
</p>
<div class="callout callout-warning">
<h4><i class="fa fa-warning"></i> Warning</h4>
Deleting this organization is permanent. It cannot be undone.
</div>
<div class="callout callout-danger validation-errors" ng-show="form.$errors">
<h4>Errors have occured</h4>
<ul>
<li ng-repeat="e in form.$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="masterPassword" class="form-control"
required api-field />
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="form.$loading">
<i class="fa fa-refresh fa-spin loading-icon" ng-show="form.$loading"></i>Delete
</button>
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
</div>
</form>

View File

@ -49,4 +49,17 @@
</div>
</form>
</div>
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title">Danger Zone</h3>
</div>
<div class="box-body">
Careful, these actions are not reversible!
</div>
<div class="box-footer">
<button type="submit" class="btn btn-default btn-flat" ng-click="delete()">
Delete Organization
</button>
</div>
</div>
</section>

View File

@ -140,6 +140,19 @@ angular
});
};
_service.removeProfileOrganization = function (orgId) {
return _service.getUserProfile().then(function (profile) {
if (profile) {
if (profile.organizations && profile.organizations.hasOwnProperty(orgId)) {
delete profile.organizations[orgId];
_userProfile = profile;
}
cryptoService.clearOrgKey(orgId);
}
});
};
_service.updateProfileOrganization = function (org) {
return _service.getUserProfile().then(function (profile) {
if (profile) {

View File

@ -193,6 +193,16 @@ angular
delete $sessionStorage.orgKeys;
};
_service.clearOrgKey = function (orgId) {
if (_orgKeys.hasOwnProperty(orgId)) {
delete _orgKeys[orgId];
}
if ($sessionStorage.orgKeys.hasOwnProperty(orgId)) {
delete $sessionStorage.orgKeys[orgId];
}
};
_service.clearKeys = function () {
_service.clearKey();
_service.clearKeyPair();

View File

@ -141,6 +141,7 @@
<script src="app/organization/organizationBillingController.js"></script>
<script src="app/organization/organizationBillingChangePaymentController.js"></script>
<script src="app/organization/organizationBillingAdjustSeatsController.js"></script>
<script src="app/organization/organizationDeleteController.js"></script>
<script src="app/settings/settingsModule.js"></script>
<script src="app/settings/settingsController.js"></script>