From 319cdfd0690a3c1fd28c7f34af1c7922d641906e Mon Sep 17 00:00:00 2001 From: Lou Knauer Date: Wed, 16 Feb 2022 09:01:47 +0100 Subject: [PATCH] Fix beeing logged out --- server.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/server.go b/server.go index 65765b2..af581f3 100644 --- a/server.go +++ b/server.go @@ -363,15 +363,21 @@ func main() { http.RedirectHandler("/", http.StatusTemporaryRedirect), // On failure: - func(rw http.ResponseWriter, r *http.Request, loginErr error) { + func(rw http.ResponseWriter, r *http.Request, err error) { rw.WriteHeader(http.StatusUnauthorized) templates.Render(rw, r, "login.tmpl", &templates.Page{ Title: "Login failed - ClusterCockpit", - Error: loginErr.Error(), + Error: err.Error(), }) })).Methods(http.MethodPost) - r.Handle("/logout", authentication.Logout(http.RedirectHandler("/login", http.StatusTemporaryRedirect))).Methods(http.MethodPost) + r.Handle("/logout", authentication.Logout(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + rw.WriteHeader(http.StatusOK) + templates.Render(rw, r, "login.tmpl", &templates.Page{ + Title: "Bye - ClusterCockpit", + Info: "Logout sucessful", + }) + }))).Methods(http.MethodPost) secured.Use(func(next http.Handler) http.Handler { return authentication.Auth( @@ -379,7 +385,7 @@ func main() { next, // On failure: - func(rw http.ResponseWriter, r *http.Request, authErr error) { + func(rw http.ResponseWriter, r *http.Request, err error) { rw.WriteHeader(http.StatusUnauthorized) templates.Render(rw, r, "login.tmpl", &templates.Page{ Title: "Authentication failed - ClusterCockpit",