Try to fix panic
This commit is contained in:
parent
3de1b8b714
commit
94735318b6
1 changed files with 6 additions and 2 deletions
|
|
@ -52,13 +52,15 @@ func (s *SessionStore) AsMiddleware(next http.Handler) http.Handler {
|
|||
// No session yet
|
||||
if err != nil {
|
||||
user := r.Header.Get("X-Auth-Request-User")
|
||||
|
||||
if user != "" {
|
||||
sessionID := s.Login(user, w)
|
||||
nextWithSessionContext(w, r, next, user, sessionID)
|
||||
} else {
|
||||
http.Redirect(w, r, "/login/", http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
session, ok := s.sessions[sessionCookie.Value]
|
||||
|
|
@ -66,13 +68,15 @@ func (s *SessionStore) AsMiddleware(next http.Handler) http.Handler {
|
|||
// Session expired
|
||||
if !ok {
|
||||
user := r.Header.Get("X-Auth-Request-User")
|
||||
|
||||
if user != "" {
|
||||
sessionID := s.Login(user, w)
|
||||
nextWithSessionContext(w, r, next, user, sessionID)
|
||||
} else {
|
||||
http.Redirect(w, r, "/login/", http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
nextWithSessionContext(w, r, next, session.User, sessionCookie.Value)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue