From 07ebc06b3252b880fdd7c5473305aca7b62b31ef Mon Sep 17 00:00:00 2001 From: juancwu Date: Wed, 14 Jan 2026 02:10:01 +0000 Subject: [PATCH] add logout route --- internal/handler/auth.go | 5 +++++ internal/routes/routes.go | 1 + 2 files changed, 6 insertions(+) diff --git a/internal/handler/auth.go b/internal/handler/auth.go index 86734d1..67b8d74 100644 --- a/internal/handler/auth.go +++ b/internal/handler/auth.go @@ -30,6 +30,11 @@ func (h *authHandler) PasswordPage(w http.ResponseWriter, r *http.Request) { ui.Render(w, r, pages.AuthPassword("")) } +func (h *authHandler) Logout(w http.ResponseWriter, r *http.Request) { + h.authService.ClearJWTCookie(w) + http.Redirect(w, r, "/", http.StatusSeeOther) +} + func (h *authHandler) SendMagicLink(w http.ResponseWriter, r *http.Request) { email := strings.TrimSpace(r.FormValue("email")) diff --git a/internal/routes/routes.go b/internal/routes/routes.go index 126388a..962d9ca 100644 --- a/internal/routes/routes.go +++ b/internal/routes/routes.go @@ -39,6 +39,7 @@ func SetupRoutes(a *app.App) http.Handler { // Auth Actions mux.HandleFunc("POST /auth/magic-link", authRateLimiter(middleware.RequireGuest(auth.SendMagicLink))) + mux.HandleFunc("POST /auth/logout", authRateLimiter(auth.Logout)) // ==================================================================================== // PRIVATE ROUTES