0

How do I disable/hide the logout link for a user on the Jasper Server UI Home Page?

Xenon
  • 3,174
  • 18
  • 37
amannam
  • 1
  • 2

1 Answers1

2

You can modify jasperserver\WEB-INF\decorators\decoratorCommonComponents.jsp file for this purpose.

The snippet of this jsp file that demonstrate how to hide logout link if user not in ADMINISTRATOR role:

<%--
***********************************************************************
authorization for logged in user
***********************************************************************
--%>
<ul id="metaLinks" class="horizontal">
    <li id="userID">
        <authz:authorize ifNotGranted="ROLE_ANONYMOUS">
            <span id="casted">
                <c:if test="<%= com.jaspersoft.jasperserver.api.metadata.user.service.impl.UserAuthorityServiceImpl.isUserSwitched() %>">
                    <%= ((com.jaspersoft.jasperserver.api.metadata.user.domain.User)
                          com.jaspersoft.jasperserver.api.metadata.user.service.impl.UserAuthorityServiceImpl.
                          getSourceAuthentication().getPrincipal()).getFullName() %>
                    <spring:message code="jsp.main.as"/>
                </c:if>
            </span>
            <authz:authentication property="principal.fullName"/>
        </authz:authorize>
    </li>
    <c:set var="isShowHelp" scope="page"><%= WebHelpLookup.getInstance().isShowHelpTrue() %></c:set>
    <c:if test="${isProVersion && isShowHelp}"><li id="help"><a href="#" id="helpLink"><spring:message code="decorator.helpLink"/></a></li></c:if>\
    <%-- We allow the logout link only for users in ROLE_ADMINISTRATOR role --%>
    <authz:authorize ifAnyGranted="ROLE_ADMINISTRATOR">
        <li id="main_logOut" class="last"><a id="main_logOut_link" href="#" onclick="javascript:return false;"><spring:message code="menu.logout"/></a></li>
    </authz:authorize>
</ul>

I've added <authz:authorize ifAnyGranted="ROLE_ADMINISTRATOR">..</authz:authorize> condition for the logout link in this jsp.

You can add another logic.

Alex K
  • 22,315
  • 19
  • 108
  • 236
  • 1
    If you only want to hide the logout link, you can more easily just add a line to custom_overrides.css. Something like this: `#main_logOut { display: none;}`. Depending on your exact needs either solution would work. – mdahlman Apr 13 '12 at 16:58
  • But if you need more secure solution, do the first one. – vahid kh Jul 28 '15 at 06:33