/** * Tests if user is in group. * * @param req The webscript request * @param userId The id of the user to test * @param groupId The if of the group to test the user against * @return true of user is in group */ protected boolean isUserInGroup(WebScriptRequest req, String userId, String groupId) { if (userId != null) { List<Group> groups = getIdentityService().findGroupsByUser(userId); for (Group group : groups) { if (config.getAdminGroupId().equals(group.getId())) { return true; } } } return false; }
/** * Tests if user has admin role. * * @param req The webscript request * @return true if the user has admin role */ protected boolean isAdmin(WebScriptRequest req) { return isUserInGroup(req, getCurrentUserId(req), config.getAdminGroupId()); }