Moved logout form inside authorized element

This commit is contained in:
neviyn 2021-06-15 10:03:03 +01:00
parent eec46598f6
commit c6bd0e2ad9

View File

@ -11,9 +11,6 @@
<link rel="stylesheet" th:href="@{/webjars/bootstrap-icons/1.4.1/font/bootstrap-icons.css}"> <link rel="stylesheet" th:href="@{/webjars/bootstrap-icons/1.4.1/font/bootstrap-icons.css}">
</div> </div>
<div th:fragment="navbar"> <div th:fragment="navbar">
<form id="logoutForm" method="POST" th:action="@{/logout}">
<input name="${_csrf.parameterName}" type="hidden" value="${_csrf.token}"/>
</form>
<nav class="navbar navbar-expand-lg navbar-light bg-light"> <nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="/"> <a class="navbar-brand" href="/">
@ -30,6 +27,9 @@
<a class="nav-link" th:href="${#mvc.url('MC#memberDetails').build()}">My Account</a> <a class="nav-link" th:href="${#mvc.url('MC#memberDetails').build()}">My Account</a>
</div> </div>
<div class="d-flex" sec:authorize="isAuthenticated()"> <div class="d-flex" sec:authorize="isAuthenticated()">
<form id="logoutForm" method="POST" th:action="@{/logout}">
<input name="${_csrf.parameterName}" type="hidden" value="${_csrf.token}"/>
</form>
<span class="navbar-text" sec:authentication="name"></span> <span class="navbar-text" sec:authentication="name"></span>
<a class="nav-link" onclick="document.forms['logoutForm'].submit()" style="cursor: pointer"><i <a class="nav-link" onclick="document.forms['logoutForm'].submit()" style="cursor: pointer"><i
class="bi bi-box-arrow-right me-1"></i>Logout</a> class="bi bi-box-arrow-right me-1"></i>Logout</a>