1
0
mirror of https://github.com/bitwarden/web synced 2025-12-06 00:03:28 +00:00

leave organization

This commit is contained in:
Kyle Spearrin
2017-04-12 10:07:16 -04:00
parent 5f130bdda7
commit f6b1666cd7
3 changed files with 47 additions and 7 deletions

View File

@@ -44,6 +44,7 @@
putUpgrade: { url: _apiUri + '/organizations/:id/upgrade', method: 'POST', params: { id: '@id' } },
putCancel: { url: _apiUri + '/organizations/:id/cancel', method: 'POST', params: { id: '@id' } },
putReinstate: { url: _apiUri + '/organizations/:id/reinstate', method: 'POST', params: { id: '@id' } },
postLeave: { url: _apiUri + '/organizations/:id/leave', method: 'POST', params: { id: '@id' } },
del: { url: _apiUri + '/organizations/:id/delete', method: 'POST', params: { id: '@id' } }
});

View File

@@ -76,6 +76,7 @@
$scope.viewOrganization = function (org) {
if (org.type === 2) { // 2 = User
scrollToTop();
toastr.error('You cannot manage this organization.');
return;
}
@@ -83,6 +84,27 @@
$state.go('backend.org.dashboard', { orgId: org.id });
};
$scope.leaveOrganization = function (org) {
if (!confirm('Are you sure you want to leave this organization (' + org.name + ')?')) {
return;
}
apiService.organizations.postLeave({ id: org.id }, {}, function (response) {
authService.refreshAccessToken().then(function () {
var index = $scope.model.organizations.indexOf(org);
if (index > -1) {
$scope.model.organizations.splice(index, 1);
}
toastr.success('You have left the organization.');
scrollToTop();
});
}, function (error) {
toastr.error('Unable to leave this organization.');
scrollToTop();
});
};
$scope.twoFactor = function () {
var twoFactorModal = $uibModal.open({
animation: true,
@@ -114,4 +136,8 @@
controller: 'settingsDeleteController'
});
};
function scrollToTop() {
$('html, body').animate({ scrollTop: 0 }, 200);
}
});

View File

@@ -114,13 +114,26 @@
No organizations yet for your account.
</div>
<div class="list-group" ng-if="model.organizations && model.organizations.length">
<a ng-repeat="org in model.organizations | orderBy: ['name']"
href="javascript:void(0)" ng-click="viewOrganization(org)" class="list-group-item">
<letter-avatar data="{{org.name}}" round="false" avwidth="25" avheight="25"
avclass="img-rounded" fontsize="10"></letter-avatar>
{{org.name}}
<span class="label bg-gray" ng-if="!org.enabled">DISABLED</span>
</a>
<div class="list-group-item" ng-repeat="org in model.organizations | orderBy: ['name']">
<div class="btn-group" uib-dropdown dropdown-append-to-body>
<button type="button" class="btn btn-default" uib-dropdown-toggle>
<i class="fa fa-cog"></i> <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu>
<li>
<a href="javascript:void(0)" ng-click="leaveOrganization(org)" class="text-red">
<i class="fa fa-fw fa-remove"></i> Leave
</a>
</li>
</ul>
</div>
<a href="javascript:void(0)" ng-click="viewOrganization(org)">
<letter-avatar data="{{org.name}}" round="false" avwidth="25" avheight="25"
avclass="img-rounded" fontsize="10"></letter-avatar>
{{org.name}}
<span class="label bg-gray" ng-if="!org.enabled">DISABLED</span>
</a>
</div>
</div>
<div class="box-footer">
<a ui-sref="backend.user.settingsCreateOrg" class="btn btn-default btn-flat">