login Developer Jahia 7.3 Jahia 8

How to determine is the user is logged in

Question

I need to alter the navigation Login buttons to Logout when the user logs in. How do I do this client side?

Answer

There are several ways to determine if a user is logged in.

The easiest way is to use the renderContext.loggedIn function that tests if the current user is a guest or not.

<c:choose>
    <c:when test="${renderContext.loggedIn}">
      // link to logout
    </c:when>
    <c:otherwise>
      // link to login
    </c:otherwise>
</c:choose>