Try to fix panic

This commit is contained in:
Maximilian Friedersdorff 2025-09-30 16:27:00 +01:00
parent 3de1b8b714
commit 94735318b6

View file

@ -52,13 +52,15 @@ func (s *SessionStore) AsMiddleware(next http.Handler) http.Handler {
// No session yet // No session yet
if err != nil { if err != nil {
user := r.Header.Get("X-Auth-Request-User") user := r.Header.Get("X-Auth-Request-User")
if user != "" { if user != "" {
sessionID := s.Login(user, w) sessionID := s.Login(user, w)
nextWithSessionContext(w, r, next, user, sessionID) nextWithSessionContext(w, r, next, user, sessionID)
} else { } else {
http.Redirect(w, r, "/login/", http.StatusFound) http.Redirect(w, r, "/login/", http.StatusFound)
return
} }
return
} }
session, ok := s.sessions[sessionCookie.Value] session, ok := s.sessions[sessionCookie.Value]
@ -66,13 +68,15 @@ func (s *SessionStore) AsMiddleware(next http.Handler) http.Handler {
// Session expired // Session expired
if !ok { if !ok {
user := r.Header.Get("X-Auth-Request-User") user := r.Header.Get("X-Auth-Request-User")
if user != "" { if user != "" {
sessionID := s.Login(user, w) sessionID := s.Login(user, w)
nextWithSessionContext(w, r, next, user, sessionID) nextWithSessionContext(w, r, next, user, sessionID)
} else { } else {
http.Redirect(w, r, "/login/", http.StatusFound) http.Redirect(w, r, "/login/", http.StatusFound)
return
} }
return
} }
nextWithSessionContext(w, r, next, session.User, sessionCookie.Value) nextWithSessionContext(w, r, next, session.User, sessionCookie.Value)