From ab713f6662cd1b82537ab4611806b6fad121af0d Mon Sep 17 00:00:00 2001 From: Teajey <21069848+Teajey@users.noreply.github.com> Date: Sat, 21 Feb 2026 10:23:19 +0900 Subject: [PATCH] Save session for basic auth --- http/mux/serve.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/http/mux/serve.go b/http/mux/serve.go index 7abcbc5..6c79b28 100644 --- a/http/mux/serve.go +++ b/http/mux/serve.go @@ -1,6 +1,7 @@ package mux import ( + "log" "net/http" "github.com/Teajey/rsvp" @@ -37,6 +38,12 @@ func (m *Serve) ServeHTTP(w http.ResponseWriter, r *http.Request) { username, password, ok := r.BasicAuth() if ok { loggedIn := nil == routing.LoginMiddle(username, password, s, r) + if s.WasWritten() { + err := s.Save(r, w) + if err != nil { + log.Printf("Failed to save session: %s", err) + } + } if loggedIn { m.Private.ServeHTTP(w, r) return