simplegit

web: restore sign out on the settings page

Deleting the /{user} profile removed the only sign-out control; the nav
got a - settings link but no logout. Add a POST /logout form under a
"session" heading on /settings, with a test asserting it renders.

d5403d04575ad43ba1a0a4f2bc3052b525602c0b
cjosie <administrator@josie-c.com> · 2026-10-16T18:41 · browse files at this commit

parents: 2fe5bbc

diff --git a/internal/web/settings_test.go b/internal/web/settings_test.go
index 41f4067..b1eb602 100644
--- a/internal/web/settings_test.go
+++ b/internal/web/settings_test.go
@@ -38,6 +38,18 @@ func TestSettingsRequiresLogin(t *testing.T) {
 	}
 }
 
+func TestSettingsHasSignOut(t *testing.T) {
+	httpServer, _, _ := newTestServer(t)
+	client := newLoggedInClient(t, httpServer)
+	resp, err := client.Get(httpServer.URL + "/settings")
+	if err != nil {
+		t.Fatalf("GET /settings: %v", err)
+	}
+	if body := readAll(t, resp); !strings.Contains(body, `action="/logout"`) {
+		t.Error("settings page has no sign-out form")
+	}
+}
+
 func TestChangePassword(t *testing.T) {
 	httpServer, _, _ := newTestServer(t)
 	josie := newLoggedInClient(t, httpServer)
diff --git a/internal/web/templates/settings.html b/internal/web/templates/settings.html
index 2e5554a..8084e59 100644
--- a/internal/web/templates/settings.html
+++ b/internal/web/templates/settings.html
@@ -43,4 +43,9 @@
   <p><label for="name">label</label> <input id="name" name="name" placeholder="laptop"></p>
   <p><button type="submit">create token</button></p>
 </form>
+
+<h2>session</h2>
+<form method="post" action="/logout">
+  <p><button type="submit">sign out</button></p>
+</form>
 {{end}}