From 7885b19b543fdbe6c441efe0ffacd89fcd7f6a67 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Tue, 14 Jan 2025 22:24:05 -0500 Subject: chore(webui): refactor login and session middleware handling --- pkg/webui/login.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pkg/webui/login.go') diff --git a/pkg/webui/login.go b/pkg/webui/login.go index d004d82..fda227a 100644 --- a/pkg/webui/login.go +++ b/pkg/webui/login.go @@ -88,9 +88,9 @@ func handleLoginPOST(db *database.DB) http.Handler { }) } -func loginMiddleware(db *database.DB) func(http.Handler) http.Handler { +func loginMiddleware(db *database.DB, requireSession func(http.Handler) http.Handler) func(http.Handler) http.Handler { return func(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + return requireSession(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "no-store, no-cache") session := r.Context().Value(model.SessionContextKey{}) if session == nil { @@ -110,6 +110,6 @@ func loginMiddleware(db *database.DB) func(http.Handler) http.Handler { } ctx := context.WithValue(r.Context(), model.AccountContextKey{}, account) next.ServeHTTP(w, r.WithContext(ctx)) - }) + })) } } -- cgit v1.2.3