Merge pull request #2462 from patriot1burke/master

KEYCLOAK-2621
This commit is contained in:
Bill Burke 2016-03-31 14:34:23 -04:00
commit 3b55bd08a6

View file

@ -1154,6 +1154,19 @@ module.controller('UserFederationMapperCreateCtrl', function($scope, realm, prov
});
function removeGroupMember(groups, member) {
for (var j = 0; j < groups.length; j++) {
//console.log('checking: ' + groups[j].path);
if (member.path == groups[j].path) {
groups.splice(j, 1);
break;
}
if (groups[j].subGroups && groups[j].subGroups.length > 0) {
//console.log('going into subgroups');
removeGroupMember(groups[j].subGroups, member);
}
}
}
module.controller('UserGroupMembershipCtrl', function($scope, $route, realm, groups, user, UserGroupMembership, UserGroupMapping, Notifications, $location, Dialog) {
$scope.realm = realm;
$scope.user = user;
@ -1163,9 +1176,15 @@ module.controller('UserGroupMembershipCtrl', function($scope, $route, realm, gro
UserGroupMembership.query({realm: realm.realm, userId: user.id}, function(data) {
$scope.groupMemberships = data;
for (var i = 0; i < data.length; i++) {
var member = data[i];
removeGroupMember(groups, member);
}
});
$scope.joinGroup = function() {
if (!$scope.tree.currentNode) {
Notifications.error('Please select a group to add');
@ -1179,6 +1198,10 @@ module.controller('UserGroupMembershipCtrl', function($scope, $route, realm, gro
};
$scope.leaveGroup = function() {
if (!$scope.selectedGroup) {
return;
}
UserGroupMapping.remove({realm: realm.realm, userId: user.id, groupId: $scope.selectedGroup.id}, function() {
Notifications.success('Removed group membership');
$route.reload();