Fix logout 405 — Django's LogoutView only accepts POST

The sidebar's "Log out" was a plain <a href> GET link. Django 5's
LogoutView stopped accepting GET (CSRF hardening — a bare link or even an
<img> tag could otherwise log someone out), so clicking it 405'd instead
of logging out. Changed it to a POST form, matching every other
state-changing action in the sidebar/app (unsubscribe, delete tag, etc.).

Extended .sidebar-top-nav's styling to cover a <button> the same as an
<a>, so the form-submit button looks identical to the other nav items.

No existing test exercised logout at all — added one for the POST case
and one confirming GET now correctly 405s, then verified end-to-end
against the running dev server (login, POST /logout/, confirm the session
is gone).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ksmithandClaude Sonnet 5 committed 2026-10-30 22:01:06 -06:00
1 parent b08a78e747
commit 1a8ae95db0
3 files changed
+38 -3

No files matched your search

+8 -2
View File
@@ -238,16 +238,22 @@ form p {
padding: 0 0.5rem;
}
.sidebar-top-nav li a {
.sidebar-top-nav li a,
.sidebar-top-nav li button {
display: block;
width: 100%;
padding: 0.4rem 0.75rem;
color: var(--text-muted);
text-decoration: none;
border: none;
border-radius: 0.375rem;
font-size: 0.9rem;
text-align: left;
background: none;
}
.sidebar-top-nav li a:hover {
.sidebar-top-nav li a:hover,
.sidebar-top-nav li button:hover {
background: var(--bg-row-hover);
color: var(--text);
}