Bug 5080: added meta permission check when adding a user to a user group

to UserManagementServiceImpl
This commit is contained in:
Steffen Jacobs authored and Steffen Schaefer committed 2019-06-27 14:19:08 +02:00
1 parent aa56707ba6
commit 647f001ea1
1 file changed
+7 -1
@@ -391,7 +391,13 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
if (userByName == null) {
throw new UserManagementException("user '" + username + "' not found.");
}
getSecurityService().addUserToUserGroup(tenant, userByName);
if (getSecurityService().hasCurrentUserMetaPermissionsOfRoleDefinitionsWithQualification(
tenant.getRoleDefinitionMap().keySet(), new Ownership(null, tenant))) {
getSecurityService().addUserToUserGroup(tenant, userByName);
} else {
throw new UnauthorizedException(
"Current user does not have all the meta permissions of the user group the user would be added to");
}
} else {
throw new UnauthorizedException("Not permitted to add user to group");
}