From 8ba3651415838279b80adaf514b4b7fd034497ce Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 28 Dec 2025 22:55:22 -0800 Subject: [PATCH] Add switch user button and logout endpoint --- main.go | 11 +++++++++++ static/home.html | 1 + 2 files changed, 12 insertions(+) diff --git a/main.go b/main.go index fe001a3..b5b235b 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ func init() { func main() { http.HandleFunc("/", handleStatic) http.HandleFunc("/auth/google/callback", handleGoogleCallback) + http.HandleFunc("/auth/logout", handleLogout) log.Println("server starting on :8080") log.Fatal(http.ListenAndServe(":8080", nil)) @@ -99,6 +100,16 @@ func setProfile(w http.ResponseWriter, profile map[string]any) { }) } +func handleLogout(w http.ResponseWriter, r *http.Request) { + http.SetCookie(w, &http.Cookie{ + Name: "profile", + Value: "", + Path: "/", + MaxAge: -1, + }) + http.Redirect(w, r, "/", http.StatusSeeOther) +} + func handleGoogleCallback(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { http.Error(w, "method not allowed", http.StatusMethodNotAllowed) diff --git a/static/home.html b/static/home.html index 4f3b067..6797722 100644 --- a/static/home.html +++ b/static/home.html @@ -38,6 +38,7 @@

Welcome to HCA Tickets!

+ Switch User