This is an automated email from the ASF dual-hosted git repository.
linkinstar pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/answer.git
The following commit(s) were added to refs/heads/dev by this push:
new 6381a219 fix: update the visit cookie if it does not match the visit
token
6381a219 is described below
commit 6381a2192e9a5118fe89c3defdbff890dec4697c
Author: Giorgio Bonvicini
<[email protected]>
AuthorDate: Fri May 23 17:57:51 2025 +0200
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 #1334
---
internal/controller/user_controller.go | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/internal/controller/user_controller.go
b/internal/controller/user_controller.go
index c8ffd7fe..49b9b23c 100644
--- a/internal/controller/user_controller.go
+++ b/internal/controller/user_controller.go
@@ -717,9 +717,12 @@ func (uc *UserController) SearchUserListByName(ctx
*gin.Context) {
}
func (uc *UserController) setVisitCookies(ctx *gin.Context, visitToken string,
force bool) {
- cookie, err := ctx.Cookie(constant.UserVisitCookiesCacheKey)
- if err == nil && len(cookie) > 0 && !force {
- return
+ if !force {
+ cookie, _ := ctx.Cookie(constant.UserVisitCookiesCacheKey)
+ // If the cookie is the same as the visitToken, no need to set
it again
+ if cookie == visitToken {
+ return
+ }
}
general, err := uc.siteInfoCommonService.GetSiteGeneral(ctx)
if err != nil {