From 032488512a927b7d6ba6ff356d63f8326b183a0c Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 31 Mar 2026 20:27:49 +0800 Subject: [PATCH] refactor(response): remove hardcoded cookie path from refresh token functions Eliminated the hardcoded path "/auth" from the SendRefreshTokenCookie functions and the DeleteAllAuthCookies function. This change enhances flexibility by allowing the cookie path to be managed more dynamically in the future. --- openapi/response/response.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/openapi/response/response.go b/openapi/response/response.go index 3286716d..a26a37d3 100644 --- a/openapi/response/response.go +++ b/openapi/response/response.go @@ -408,7 +408,6 @@ func SendAccessTokenCookieWithDuration(c *gin.Context, accessToken string, durat func SendRefreshTokenCookie(c *gin.Context, refreshToken string, maxAge int) { options := NewSecureCookieOptions(). WithMaxAge(maxAge). - WithPath("/auth"). WithSameSite("Strict") SendSecureCookieWithOptions(c, "refresh_token", refreshToken, options) } @@ -417,7 +416,6 @@ func SendRefreshTokenCookie(c *gin.Context, refreshToken string, maxAge int) { func SendRefreshTokenCookieWithExpiry(c *gin.Context, refreshToken string, expires time.Time) { options := NewSecureCookieOptions(). WithExpires(expires). - WithPath("/auth"). WithSameSite("Strict") SendSecureCookieWithOptions(c, "refresh_token", refreshToken, options) } @@ -426,7 +424,6 @@ func SendRefreshTokenCookieWithExpiry(c *gin.Context, refreshToken string, expir func SendRefreshTokenCookieWithDuration(c *gin.Context, refreshToken string, duration time.Duration) { options := NewSecureCookieOptions(). WithDuration(duration). - WithPath("/auth"). WithSameSite("Strict") SendSecureCookieWithOptions(c, "refresh_token", refreshToken, options) } @@ -442,10 +439,9 @@ func DeleteAllAuthCookies(c *gin.Context) { DeleteSecureCookie(c, "session_id") DeleteSecureCookie(c, "access_token") - // Also delete refresh token with its specific path + // Also delete refresh token cookie options := NewSecureCookieOptions(). - WithMaxAge(-1). - WithPath("/auth") + WithMaxAge(-1) SendSecureCookieWithOptions(c, "refresh_token", "", options) }