Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logout link with Spring and Thymeleaf

Tags:

According with the official example (Secure Web Content), I have to use a form and a button with the aim to perform a logout with Spring Security. Is there a way to use a link with Thymeleaf instead of a button?

like image 342
vdenotaris Avatar asked Mar 21 '14 11:03

vdenotaris


1 Answers

You have to use a form for log out. If you really want a link, you can use JavaScript to have the link perform a POST on a hidden form.

<a href="javascript: document.logoutForm.submit()" role="menuitem"> Logout</a>

   <form name="logoutForm" th:action="@{/logout}" method="post" th:hidden="true">
      <input hidden type="submit" value="Sign Out"/>
   </form> 
like image 96
skouda Avatar answered Sep 25 '22 03:09

skouda