From 428d29b176646fae52ff0bd1786fd17fc7475ae3 Mon Sep 17 00:00:00 2001 From: Andy Oknen Date: Wed, 30 Jul 2025 16:15:34 +0000 Subject: [PATCH] Update authMiddleware to redirect to main page if no password is set and user accesses login page --- src/webui/server.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/webui/server.go b/src/webui/server.go index da2bdffd..6f074780 100644 --- a/src/webui/server.go +++ b/src/webui/server.go @@ -201,8 +201,12 @@ func (w *WebUIServer) cleanupExpiredSessions() { // authMiddleware checks for valid session or redirects to login func (w *WebUIServer) authMiddleware(next http.HandlerFunc) http.HandlerFunc { return func(rw http.ResponseWriter, r *http.Request) { - // Skip authentication if no password is set + // If no password is set and user tries to access login page, redirect to main page if w.password == "" { + if r.URL.Path == "/login.html" { + http.Redirect(rw, r, "/", http.StatusSeeOther) + return + } next(rw, r) return }