Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public final Response deleteToolGroupFromUser(@Context final HttpServletRequest
.init()
.getUser();

if (!loggedInUser.isAdmin()) {
throw new DotSecurityException(
"User does not have permission to remove layouts from users");
}

if (null != userid){
user = APILocator.getUserAPI().loadUserById(userid, loggedInUser, true);
}
Expand Down Expand Up @@ -116,6 +121,11 @@ public final Response addToolGroupToUser(@Context final HttpServletRequest reque
.init()
.getUser();

if (!layoutId.equalsIgnoreCase("gettingstarted") && !loggedInUser.isAdmin()) {
throw new DotSecurityException(
"User does not have permission to assign layouts");
}

if (null != userid){
user = APILocator.getUserAPI().loadUserById(userid, loggedInUser, true);
}
Expand Down
18 changes: 16 additions & 2 deletions dotCMS/src/main/java/com/dotmarketing/business/ajax/RoleAjax.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,14 @@ private Map<String, Object> getUserMap(final User user)
public void removeUsersFromRole(String[] userIds, String roleId) throws DotDataException, NoSuchUserException, DotRuntimeException, PortalException, SystemException, DotSecurityException {

//Validate if this logged in user has the required permissions to access the roles portlet
validateRolesPortletPermissions(getLoggedInUser());
final User callerForRemove = getLoggedInUser();
validateRolesPortletPermissions(callerForRemove);
if (!callerForRemove.isAdmin()) {
SecurityLogger.logInfo(getClass(),
"Unauthorized attempt to remove role by user " + callerForRemove.getUserId());
throw new DotSecurityException(
"User does not have permission to remove roles from users");
}

WebContext ctx = WebContextFactory.get();
RoleAPI roleAPI = APILocator.getRoleAPI();
Expand Down Expand Up @@ -310,7 +317,14 @@ public void removeUsersFromRole(String[] userIds, String roleId) throws DotDataE
public Map<String, Object> addUserToRole(String userId, String roleId) throws DotDataException, DotRuntimeException, PortalException, SystemException, DotSecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {

//Validate if this logged in user has the required permissions to access the roles portlet
validateRolesPortletPermissions(getLoggedInUser());
final User caller = getLoggedInUser();
validateRolesPortletPermissions(caller);
if (!caller.isAdmin()) {
SecurityLogger.logInfo(getClass(),
"Unauthorized attempt to assign role by user " + caller.getUserId());
throw new DotSecurityException(
"User does not have permission to assign roles to users");
}

WebContext ctx = WebContextFactory.get();
RoleAPI roleAPI = APILocator.getRoleAPI();
Expand Down
Loading