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

Time:03-20

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 .

CodePudding user response:

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.

  • Related