add logout route

This commit is contained in:
juancwu 2026-01-14 02:10:01 +00:00
commit 07ebc06b32
2 changed files with 6 additions and 0 deletions

View file

@ -30,6 +30,11 @@ func (h *authHandler) PasswordPage(w http.ResponseWriter, r *http.Request) {
ui.Render(w, r, pages.AuthPassword("")) 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) { func (h *authHandler) SendMagicLink(w http.ResponseWriter, r *http.Request) {
email := strings.TrimSpace(r.FormValue("email")) email := strings.TrimSpace(r.FormValue("email"))

View file

@ -39,6 +39,7 @@ func SetupRoutes(a *app.App) http.Handler {
// Auth Actions // Auth Actions
mux.HandleFunc("POST /auth/magic-link", authRateLimiter(middleware.RequireGuest(auth.SendMagicLink))) mux.HandleFunc("POST /auth/magic-link", authRateLimiter(middleware.RequireGuest(auth.SendMagicLink)))
mux.HandleFunc("POST /auth/logout", authRateLimiter(auth.Logout))
// ==================================================================================== // ====================================================================================
// PRIVATE ROUTES // PRIVATE ROUTES