From 4dc9b4c0de258626fa405c3b920c3e22683f70eb Mon Sep 17 00:00:00 2001 From: Adam French Date: Wed, 10 Dec 2025 06:06:37 +0000 Subject: [PATCH] bugfix --- backend/handlers/handle_auth.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/backend/handlers/handle_auth.go b/backend/handlers/handle_auth.go index 38bb985..cea3d8a 100644 --- a/backend/handlers/handle_auth.go +++ b/backend/handlers/handle_auth.go @@ -52,6 +52,7 @@ func (store *Store) CheckToken(ctx *gin.Context) { tx := store.DB.First(&user) if tx.Error != nil { ctx.JSON(http.StatusNotFound, tx.Error.Error()) + removeCookies(ctx) return } @@ -83,6 +84,7 @@ func (store *Store) RefreshToken(ctx *gin.Context) { tx := store.DB.First(&user, userID) if tx.Error != nil { ctx.JSON(http.StatusNotFound, tx.Error.Error()) + removeCookies(ctx) return } @@ -157,22 +159,26 @@ func (store *Store) Login(ctx *gin.Context) { } func (store *Store) Logout(ctx *gin.Context) { + removeCookies(ctx) + + ctx.Status(http.StatusOK) +} + +func removeCookies(ctx *gin.Context) { ctx.SetCookie( "access_token", "", -1, - store.Auth.Config.Endpoint, - store.Auth.Config.Domain, + "", + "", true, true, ) ctx.SetCookie( "refresh_token", "", -1, - store.Auth.Config.Endpoint, - store.Auth.Config.Domain, + "", + "", true, true, ) - - ctx.Status(http.StatusOK) }