diff --git a/handlers/auth.go b/handlers/auth.go index 965408a..e047e1e 100644 --- a/handlers/auth.go +++ b/handlers/auth.go @@ -50,6 +50,7 @@ func (h *Handler) Callback(w http.ResponseWriter, r *http.Request) { func (h *Handler) Logout(w http.ResponseWriter, r *http.Request) { session, err := gothic.Store.Get(r, "user-session") if err != nil { + fmt.Printf("error retrieving session: %v", err) return } @@ -62,5 +63,12 @@ func (h *Handler) Logout(w http.ResponseWriter, r *http.Request) { return } + http.SetCookie(w, &http.Cookie{ + Name: "user-session", // or whatever your session name is + Value: "", + Path: "/", + MaxAge: -1, // This deletes the cookie + }) + http.Redirect(w, r, "/", http.StatusFound) } diff --git a/main.go b/main.go index 583f977..3a11ffa 100644 --- a/main.go +++ b/main.go @@ -22,8 +22,8 @@ func main() { if err != nil { panic("HELP ME LOAD SOME ENV FILE") } - tmpl, err := template.ParseGlob("templates/*.html") + tmpl, err := template.ParseGlob("templates/*.html") if err != nil { panic(fmt.Errorf("failed to parse templates: %w\n", err)) } @@ -42,7 +42,7 @@ func main() { // auth routes mux.HandleFunc("/auth/twitch", h.Auth) mux.HandleFunc("/auth/twitch/callback", h.Callback) - mux.HandleFunc("/logout/", h.Logout) + mux.HandleFunc("/logout", h.Logout) // pages route mux.HandleFunc("/", h.Home) diff --git a/templates/welcome.html b/templates/welcome.html index ca732aa..f68c5ee 100644 --- a/templates/welcome.html +++ b/templates/welcome.html @@ -9,7 +9,7 @@
-