Compare commits

..

2 Commits

Author SHA1 Message Date
f7b8018c62 Redirect from /auth to / when logged in 2018-10-01 22:29:29 +02:00
6c06f49279 Calculate nextURI and redirect 2018-10-01 22:29:14 +02:00

View File

@ -31,6 +31,10 @@ func (h *IndieAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer sess.Flush()
if r.Method == http.MethodGet {
if sess.LoggedIn {
http.Redirect(w, r, "/", 302)
return
}
if r.URL.Path == "" {
fmt.Fprint(w, `<!doctype html>
<html>
@ -78,12 +82,11 @@ func (h *IndieAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
sess.Me = authResponse.Me
sess.LoggedIn = true
log.Printf("SESSION: %#v\n", sess)
nextURI := "/"
if sess.NextURI != "" {
http.Redirect(w, r, sess.NextURI, 302)
} else {
http.Redirect(w, r, "/", 302)
nextURI = sess.NextURI
}
http.Redirect(w, r, nextURI, 302)
return
}
return