I am using spring for my application. Listed below are some lines from my Context-Security.xml application to set access as ROLE_USER for / suggestions and / add links and there are no filters for the link / list.
<intercept-url pattern="/list*" filters="none" /> <intercept-url pattern="/offers**" access="ROLE_USER" /> <intercept-url pattern="/add/**" access="ROLE_USER" />
I want to show the LOGIN link when the user is not logged in and when the user logs in, then this link should be replaced with LOGOUT . For this, I tried the following code on my jsp page.
<security:authorize ifNotGranted="ROLE_USER"> <a href="login.jsp">Login</a> </security:authorize> <security:authorize ifAnyGranted="ROLE_USER"> Welcome <security:authentication property="principal.username"/>! | <a href="logout.htm">Logout</a> </security:authorize>
When I am in the list / list, it shows the "ENTRANCE" link. After logging in, if the user is redirected to / offers or / adds a link, he displays "Welcome UserName | LOGOUT", which works as requested. But the problem is that when a user logs in and redirects to the / list page, it also shows "LOGIN" (USER is already registered). It should show "Welcome UserName | LOGOUT"
Help me in this scenario: what should I do to make it work? Thank you in advance.
source share