Skip to content
Advertisement

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 .

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement