Compare commits
4 Commits
f039df69a5
...
67e617c969
| Author | SHA1 | Date | |
|---|---|---|---|
| 67e617c969 | |||
| ed336fe39a | |||
| 4c1b768a09 | |||
| 28d7d953e2 |
|
|
@ -516,28 +516,29 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
sess, err := loadSession(sessionVar, conn)
|
sess, err := loadSession(sessionVar, conn)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
http.Redirect(w, r, "/", 302)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
sess.AuthorizationEndpoint = endpoints.AuthorizationEndpoint
|
sess.AuthorizationEndpoint = endpoints.AuthorizationEndpoint
|
||||||
sess.Me = meURL.String()
|
sess.Me = meURL.String()
|
||||||
sess.State = state
|
sess.State = state
|
||||||
sess.RedirectURI = redirectURI
|
sess.RedirectURI = redirectURI
|
||||||
sess.LoggedIn = false
|
sess.LoggedIn = false
|
||||||
saveSession(sessionVar, &sess, conn)
|
|
||||||
|
|
||||||
authenticationURL := indieauth.CreateAuthenticationURL(*authURL, meURL.String(), ClientID, redirectURI, state)
|
err = saveSession(sessionVar, &sess, conn)
|
||||||
|
if err != nil {
|
||||||
http.Redirect(w, r, authenticationURL, 302)
|
|
||||||
return
|
|
||||||
} else if r.URL.Path == "/session/logout" {
|
|
||||||
c, err := r.Cookie("session")
|
|
||||||
|
|
||||||
if err == http.ErrNoCookie {
|
|
||||||
http.Redirect(w, r, "/", 302)
|
http.Redirect(w, r, "/", 302)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionVar := c.Value
|
authenticationURL := indieauth.CreateAuthenticationURL(*authURL, meURL.String(), ClientID, redirectURI, state)
|
||||||
conn.Do("DEL", "session:"+sessionVar)
|
http.Redirect(w, r, authenticationURL, 302)
|
||||||
http.Redirect(w, r, "/", 302)
|
|
||||||
|
return
|
||||||
|
} else if r.URL.Path == "/session/logout" {
|
||||||
|
httpSessionLogout(r, w, conn)
|
||||||
return
|
return
|
||||||
} else if r.URL.Path == "/auth/approve" {
|
} else if r.URL.Path == "/auth/approve" {
|
||||||
// create a code
|
// create a code
|
||||||
|
|
@ -668,3 +669,16 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func httpSessionLogout(r *http.Request, w http.ResponseWriter, conn redis.Conn) {
|
||||||
|
c, err := r.Cookie("session")
|
||||||
|
if err == http.ErrNoCookie {
|
||||||
|
http.Redirect(w, r, "/", 302)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
sessionVar := c.Value
|
||||||
|
_, _ = conn.Do("DEL", "session:"+sessionVar)
|
||||||
|
}
|
||||||
|
http.Redirect(w, r, "/", 302)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ func NewApp(options AppOptions) (*App, error) {
|
||||||
|
|
||||||
http.Handle("/micropub", µpubHandler{
|
http.Handle("/micropub", µpubHandler{
|
||||||
Backend: app.backend,
|
Backend: app.backend,
|
||||||
|
pool: options.pool,
|
||||||
})
|
})
|
||||||
|
|
||||||
handler, broker := server.NewMicrosubHandler(app.backend)
|
handler, broker := server.NewMicrosubHandler(app.backend)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user