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