1
0
mirror of synced 2026-08-04 09:17:02 +00:00

Hide logout in main.jsp if not logged in

This commit is contained in:
Rob Winch
2013-08-17 14:38:39 -05:00
parent 5fe32bb3c8
commit 51b9c4a19a
11 changed files with 82 additions and 61 deletions
+12 -8
View File
@@ -80,16 +80,18 @@ include::hello-includes/exploring-the-secured-application.asc[]
==== Displaying the user name
Now that we have authenticated, let's update the application to display the username. Update main.jsp to contain the following snippet:
Now that we have authenticated, let's update the application to display the username if the user is authenticated. Update main.jsp to contain the following snippet:
.src/main/webapp/WEB-INF/decorators/main.jsp
[source,html]
[subs="verbatim,quotes"]
----
<div class="nav-collapse collapse">
*<p class="navbar-text pull-right">
<c:out value="${pageContext.request.remoteUser}"/>
</p>*
*<c:if test="${pageContext.request.remoteUser != null}">
<p class="navbar-text pull-right">
<c:out value="${pageContext.request.remoteUser}"/>
</p>
</c:if>*
<ul class="nav">
<c:url var="inboxUrl" value="/"/>
<li><a href="${inboxUrl}">Inbox</a></li>
@@ -112,10 +114,12 @@ Now that we can view the user name, let's update the application to allow loggin
[subs="verbatim,quotes"]
----
<div class="nav-collapse collapse">
*<c:url var="logoutUrl" value="/logout"/>
<form:form class="navbar-form pull-right" action="${logoutUrl}" method="post">
<input type="submit" value="Log out" />
</form:form>*
*<c:if test="${pageContext.request.remoteUser != null}">
<c:url var="logoutUrl" value="/logout"/>
<form:form class="navbar-form pull-right" action="${logoutUrl}" method="post">
<input type="submit" value="Log out" />
</form:form>
</c:if>*
<p class="navbar-text pull-right">
<c:out value="${pageContext.request.remoteUser}"/>
</p>