Skip to content

Commit 5227831

Browse files
fix: update the visit cookie if it does not match the visit token
Previous behavior was to keep any existing visit cookies, which caused problems like apache#1334
1 parent 3f1ed50 commit 5227831

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/controller/user_controller.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,12 @@ func (uc *UserController) SearchUserListByName(ctx *gin.Context) {
717717
}
718718

719719
func (uc *UserController) setVisitCookies(ctx *gin.Context, visitToken string, force bool) {
720-
cookie, err := ctx.Cookie(constant.UserVisitCookiesCacheKey)
721-
if err == nil && len(cookie) > 0 && !force {
722-
return
720+
if !force {
721+
cookie, _ := ctx.Cookie(constant.UserVisitCookiesCacheKey)
722+
// If the cookie is the same as the visitToken, no need to set it again
723+
if cookie == visitToken {
724+
return
725+
}
723726
}
724727
general, err := uc.siteInfoCommonService.GetSiteGeneral(ctx)
725728
if err != nil {

0 commit comments

Comments
 (0)