Skip to content

Commit

Permalink
bugfix: cookies remover on chromium
Browse files Browse the repository at this point in the history
  • Loading branch information
ARUMANDESU committed May 28, 2024
1 parent a70434d commit 67305b9
Showing 1 changed file with 6 additions and 30 deletions.
36 changes: 6 additions & 30 deletions internal/handler/user/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())})
}

Expand Down Expand Up @@ -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())})
}

Expand Down

0 comments on commit 67305b9

Please sign in to comment.