switch logout links to a single universal form

This commit is contained in:
Sky Johnson 2025-08-25 16:55:55 -05:00
parent bbd515bc57
commit ef95b70eb9
4 changed files with 21 additions and 6 deletions

View File

@ -105,6 +105,7 @@ a {
color: #663300; color: #663300;
text-decoration: none; text-decoration: none;
font-weight: bold; font-weight: bold;
cursor: pointer;
&:hover { &:hover {
color: #330000; color: #330000;
@ -580,4 +581,8 @@ div.bottom-reply {
hr { hr {
margin: 1rem 0; margin: 1rem 0;
}
.hidden {
display: none;
} }

View File

@ -56,7 +56,16 @@
{yield "scripts"} {yield "scripts"}
<script> <script>
document.addEventListener('DOMContentLoaded', addSelectArrows) document.addEventListener('DOMContentLoaded', () => {
addSelectArrows()
document.querySelectorAll('.logout-link').forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault()
document.getElementById('logout-form').submit()
})
})
})
</script> </script>
</body> </body>
</html> </html>

View File

@ -49,10 +49,14 @@
<a href="/">Home</a> <a href="/">Home</a>
<a href="/forum">Forum</a> <a href="/forum">Forum</a>
<a href="/change-password">Change Password</a> <a href="/change-password">Change Password</a>
<a href="#">Log Out</a> <a class="logout-link">Log Out</a>
<a href="/help">Help</a> <a href="/help">Help</a>
</section> </section>
<form id="logout-form" class="hidden" action="/logout" method="post">
{csrf}
</form>
<script> <script>
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const teleportModal = new ConfirmModal({ const teleportModal = new ConfirmModal({

View File

@ -1,8 +1,5 @@
{if authenticated} {if authenticated}
<form action="/logout" method="post" class="logout"> <a class="logout-link"><img src="/assets/images/button_logout.gif" alt="Log Out" title="Log Out"></a>
{csrf}
<button class="img-button" type="submit"><img src="/assets/images/button_logout.gif" alt="Log Out" title="Log Out"></button>
</form>
<a href="/help"><img src="/assets/images/button_help.gif" alt="Help" title="Help"></a> <a href="/help"><img src="/assets/images/button_help.gif" alt="Help" title="Help"></a>
{else} {else}
<a href="/login"><img src="/assets/images/button_login.gif" alt="Log In" title="Log In"></a> <a href="/login"><img src="/assets/images/button_login.gif" alt="Log In" title="Log In"></a>