1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 17:23:37 +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

@@ -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);
}
});