vendredi 6 mars 2015

thymeleaf check if user is logged in or not

I'm using Spring boot with Thymeleaf and Spring security. I have got a simple view with login link. When user logs in, I'd like to change login link to logout link.


I tried:



<div sec:authorize="#{isAuthenticated()}">
<a th:href="@{/logout}">Log out</a>
</div>
<div sec:authorize="#{isAnonymous()}">
<a th:href="@{/login}">Log in</a>
</div>


but it's not working - it displays both links.


Best regards.


Aucun commentaire:

Enregistrer un commentaire