Merge pull request #2748 from thomasdarimont/issue/KEYCLOAK-2924-AdminEvents-on-group-membership-changes

KEYCLOAK-2924: Fire AdminEvents on user group membership changes.
This commit is contained in:
Stian Thorgersen 2016-04-28 08:37:46 +02:00
commit acba6cd210

View file

@ -960,7 +960,10 @@ public class UsersResource {
}
try {
if (user.isMemberOf(group)) user.leaveGroup(group);
if (user.isMemberOf(group)){
user.leaveGroup(group);
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
}
} catch (ModelException me) {
Properties messages = AdminRoot.getMessages(session, realm, auth.getAuth().getToken().getLocale());
throw new ErrorResponseException(me.getMessage(), MessageFormat.format(messages.getProperty(me.getMessage(), me.getMessage()), me.getParameters()),
@ -982,7 +985,10 @@ public class UsersResource {
if (group == null) {
throw new NotFoundException("Group not found");
}
if (!user.isMemberOf(group)) user.joinGroup(group);
if (!user.isMemberOf(group)){
user.joinGroup(group);
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo).success();
}
}