Create a session when starting at auth
This commit is contained in:
parent
d9bdf78fd2
commit
4078559a89
|
|
@ -392,20 +392,19 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
} else if r.URL.Path == "/auth" {
|
} else if r.URL.Path == "/auth" {
|
||||||
// check if we are logged in
|
// check if we are logged in
|
||||||
// TODO: if not logged in, make sure we get back here
|
// TODO: if not logged in, make sure we get back here
|
||||||
c, err := r.Cookie("session")
|
|
||||||
if err == http.ErrNoCookie {
|
sessionVar := getSessionCookie(w, r)
|
||||||
http.Redirect(w, r, "/", 302)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
sessionVar := c.Value
|
|
||||||
sess, err := loadSession(sessionVar, conn)
|
sess, err := loadSession(sessionVar, conn)
|
||||||
|
|
||||||
if !isLoggedIn(h.Backend, &sess) {
|
if !isLoggedIn(h.Backend, &sess) {
|
||||||
|
sess.NextURI = r.URL.String()
|
||||||
|
saveSession(sessionVar, &sess, conn)
|
||||||
http.Redirect(w, r, "/", 302)
|
http.Redirect(w, r, "/", 302)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sess.NextURI = r.URL.String()
|
|
||||||
|
|
||||||
|
sess.NextURI = r.URL.String()
|
||||||
saveSession(sessionVar, &sess, conn)
|
saveSession(sessionVar, &sess, conn)
|
||||||
|
|
||||||
query := r.URL.Query()
|
query := r.URL.Query()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user