From 28d7d953e2ceb972355cf960482d9f9746bbe1c1 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Mon, 13 May 2019 21:28:36 +0200 Subject: [PATCH] Handle errors --- cmd/eksterd/http.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/eksterd/http.go b/cmd/eksterd/http.go index 73f8dda..87ad089 100644 --- a/cmd/eksterd/http.go +++ b/cmd/eksterd/http.go @@ -516,16 +516,26 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { sess, err := loadSession(sessionVar, conn) + if err != nil { + http.Redirect(w, r, "/", 302) + return + } + sess.AuthorizationEndpoint = endpoints.AuthorizationEndpoint sess.Me = meURL.String() sess.State = state sess.RedirectURI = redirectURI sess.LoggedIn = false - saveSession(sessionVar, &sess, conn) + + err = saveSession(sessionVar, &sess, conn) + if err != nil { + http.Redirect(w, r, "/", 302) + return + } authenticationURL := indieauth.CreateAuthenticationURL(*authURL, meURL.String(), ClientID, redirectURI, state) - http.Redirect(w, r, authenticationURL, 302) + return } else if r.URL.Path == "/session/logout" { c, err := r.Cookie("session")