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
|
// 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)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue