'SpringBoot - i want to show login button for only users that are not logged-in

I am currently looking for a solution on how to not show the login button when a user is fully authenticated. This is for a personal project that I am doing. I want users to not be able to view the login button if they are connected, i already tried to look in the thymeleaf documentation i didn't find an answer .



Solution 1:[1]

If you are using Spring Security, you can do something like:

              <li th:ref="navbar-item" sec:authorize="!isAuthenticated()">
                <a th:text="'Login'" th:href="@{/login}"/>
              </li>

For the complete context, take a look at my blog article and the corresponding source on GitHub.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Allen D. Ball