From a74087aa2ae0b78778005c626dd38fddfbb993cd Mon Sep 17 00:00:00 2001 From: mkelvers Date: Sat, 27 Jun 2026 21:05:41 +0200 Subject: [PATCH] fix: change logout route from GET to POST --- internal/auth/handler.go | 4 ++-- internal/auth/middleware.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/auth/handler.go b/internal/auth/handler.go index 8794fb80..7928bfce 100644 --- a/internal/auth/handler.go +++ b/internal/auth/handler.go @@ -20,7 +20,7 @@ func NewAuthHandler(svc domain.AuthService) *AuthHandler { func (h *AuthHandler) Register(r *gin.Engine) { r.GET("/login", h.HandleLoginPage) r.POST("/login", h.HandleLogin) - r.GET("/logout", h.HandleLogout) + r.POST("/logout", h.HandleLogout) r.POST("/api/auth/login", h.HandleAPILogin) } @@ -60,7 +60,7 @@ func (h *AuthHandler) HandleLogout(c *gin.Context) { } } - c.SetCookie("session_id", "", -1, "/", "", false, true) + clearSessionCookie(c) c.Redirect(http.StatusSeeOther, "/login") } diff --git a/internal/auth/middleware.go b/internal/auth/middleware.go index 4599fea7..9090461f 100644 --- a/internal/auth/middleware.go +++ b/internal/auth/middleware.go @@ -18,7 +18,7 @@ var publicRoutes = []publicRoute{ // Pages. {method: http.MethodGet, path: "/login"}, {method: http.MethodPost, path: "/login"}, - {method: http.MethodGet, path: "/logout"}, + {method: http.MethodPost, path: "/logout"}, // Crawler noise. {method: http.MethodGet, path: "/robots.txt"},