From c84cea1d5cf0d000198697a815e9f0be890f05b7 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Mon, 1 Oct 2018 22:20:29 +0200 Subject: [PATCH] Introduce cleanupSession function --- indieauth.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/indieauth.go b/indieauth.go index b5610c8..3871c09 100644 --- a/indieauth.go +++ b/indieauth.go @@ -88,12 +88,7 @@ func (h *IndieAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } return } else if r.URL.Path == "logout" { - sess.LoggedIn = false - sess.State = "" - sess.Me = "" - sess.AuthorizationEndpoint = "" - sess.NextURI = "" - sess.RedirectURI = "" + cleanupSession(sess) http.Redirect(w, r, "/", 302) return } @@ -137,3 +132,12 @@ func (h *IndieAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } } + +func cleanupSession(sess *Session) { + sess.LoggedIn = false + sess.State = "" + sess.Me = "" + sess.AuthorizationEndpoint = "" + sess.NextURI = "" + sess.RedirectURI = "" +}