Skip to content

Commit

Permalink
Changed visibility of 'Switch user' to allow OU administrator to use it.
Browse files Browse the repository at this point in the history
  • Loading branch information
tHerrmann committed Mar 24, 2017
1 parent d18516b commit 501ff78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,13 @@ public boolean isVisible(CmsWorkplace wp) {
} else if (getLink().equals(getPath(OUROLES_FILE))) {
return !m_webuserOu;
} else if (getLink().equals(getPath(SWITCHUSER_FILE))) {
boolean visible = OpenCms.getRoleManager().hasRole(cms, CmsRole.ROOT_ADMIN);
boolean visible = false;
CmsUUID userId = new CmsUUID(
CmsRequestUtil.getNotEmptyDecodedParameter(wp.getJsp().getRequest(), A_CmsEditUserDialog.PARAM_USERID));
try {
visible &= OpenCms.getRoleManager().hasRole(
cms,
cms.readUser(userId).getName(),
CmsRole.ELEMENT_AUTHOR);
CmsUser user = cms.readUser(userId);
visible = OpenCms.getRoleManager().hasRole(cms, CmsRole.ADMINISTRATOR.forOrgUnit(user.getOuFqn()));
visible &= OpenCms.getRoleManager().hasRole(cms, user.getName(), CmsRole.ELEMENT_AUTHOR);
} catch (CmsException e) {
// should never happen
if (LOG.isErrorEnabled()) {
Expand Down
13 changes: 6 additions & 7 deletions src/org/opencms/main/CmsSessionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public void sendBroadcast(CmsUser fromUser, String message, CmsUser toUser) {
public String switchUser(CmsObject cms, HttpServletRequest req, CmsUser user) throws CmsException {

// only user with root administrator role are allowed to switch the user
OpenCms.getRoleManager().checkRole(cms, CmsRole.ROOT_ADMIN.forOrgUnit(user.getOuFqn()));
OpenCms.getRoleManager().checkRole(cms, CmsRole.ADMINISTRATOR.forOrgUnit(user.getOuFqn()));
CmsSessionInfo info = getSessionInfo(req);
HttpSession session = req.getSession(false);
if ((info == null) || (session == null)) {
Expand Down Expand Up @@ -679,12 +679,11 @@ protected void sessionCreated(HttpSessionEvent event) {
m_sessionCountCurrent = (m_sessionCountCurrent <= 0) ? 1 : (m_sessionCountCurrent + 1);
m_sessionCountTotal++;
if (LOG.isInfoEnabled()) {
LOG.info(
tid
+ Messages.get().getBundle().key(
Messages.LOG_SESSION_CREATED_2,
new Integer(m_sessionCountTotal),
new Integer(m_sessionCountCurrent)));
LOG.info(tid
+ Messages.get().getBundle().key(
Messages.LOG_SESSION_CREATED_2,
new Integer(m_sessionCountTotal),
new Integer(m_sessionCountCurrent)));
}
}

Expand Down

0 comments on commit 501ff78

Please sign in to comment.