From fd89e5586bdbdf5e55057348c82306f33718cdb8 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Fri, 6 Oct 2023 15:46:14 +0300 Subject: [PATCH] fix: fix cookie issue --- middlewares/auth.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/middlewares/auth.go b/middlewares/auth.go index 5d1b65b..14f4f6d 100644 --- a/middlewares/auth.go +++ b/middlewares/auth.go @@ -33,8 +33,6 @@ func IsAuthenticated(c *gin.Context) { "SELECT EXISTS(SELECT 1 FROM users WHERE id = $1)", user.Id).Scan(&exists) if err != nil || !exists { - c.Redirect(http.StatusSeeOther, "/login") - c.Abort() session.Clear() if err := session.Save(); err != nil { errStr := "Failed to save session" @@ -42,6 +40,9 @@ func IsAuthenticated(c *gin.Context) { util.RenderError(c, "session error", errStr, nil) return } + c.Redirect(http.StatusSeeOther, "/login") + c.Abort() + return } c.Next() -- 2.44.1