From 67305b9ace6f2ea205dbea9aaa94bf61da843151 Mon Sep 17 00:00:00 2001 From: ARUMANDESU Date: Wed, 29 May 2024 04:46:36 +0500 Subject: [PATCH] bugfix: cookies remover on chromium --- internal/handler/user/auth.go | 36 ++++++----------------------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/internal/handler/user/auth.go b/internal/handler/user/auth.go index 6deb3b2..eda68c7 100755 --- a/internal/handler/user/auth.go +++ b/internal/handler/user/auth.go @@ -102,21 +102,9 @@ func (h *Handler) SignIn(c *gin.Context) { return } - refreshTokenCookie := &http.Cookie{ - Name: RefreshTokenName, - Value: res.GetRtToken(), - Expires: time.Now().Add(time.Hour * 24 * 30), - HttpOnly: true, - Path: "/", - } - accessTokenCookie := &http.Cookie{ - Name: AccessTokenName, - Value: res.GetJwtToken(), - Expires: time.Now().Add(time.Hour * 24 * 30), - Path: "/", - } - http.SetCookie(c.Writer, refreshTokenCookie) - http.SetCookie(c.Writer, accessTokenCookie) + c.SetCookie(RefreshTokenName, res.GetRtToken(), int(time.Hour*24*30), "/", "", false, true) + c.SetCookie(AccessTokenName, res.GetJwtToken(), int(time.Hour*24*30), "/", "", false, false) + c.JSON(http.StatusOK, gin.H{"user": domain.UserObjectToDomain(res.GetUser())}) } @@ -183,21 +171,9 @@ func (h *Handler) RefreshTokenHandler(c *gin.Context) { return } - refreshTokenCookie := &http.Cookie{ - Name: RefreshTokenName, - Value: res.GetRtToken(), - Expires: time.Now().Add(time.Hour * 24 * 30), - HttpOnly: true, - Path: "/", - } - accessTokenCookie := &http.Cookie{ - Name: AccessTokenName, - Value: res.GetJwtToken(), - Expires: time.Now().Add(time.Hour * 24 * 30), - Path: "/", - } - http.SetCookie(c.Writer, refreshTokenCookie) - http.SetCookie(c.Writer, accessTokenCookie) + c.SetCookie(RefreshTokenName, res.GetRtToken(), int(time.Hour*24*30), "/", "", false, true) + c.SetCookie(AccessTokenName, res.GetJwtToken(), int(time.Hour*24*30), "/", "", false, false) + c.JSON(http.StatusOK, gin.H{"user": domain.UserObjectToDomain(res.GetUser())}) }