Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/1.4.5/file' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkinStars committed Jan 13, 2025
2 parents dd4b3e8 + a5d826c commit dae16c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions internal/base/middleware/visit_img_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@
package middleware

import (
"github.com/apache/answer/internal/base/constant"
"github.com/gin-gonic/gin"
"net/http"
"os"
"strings"

"github.com/apache/answer/internal/base/constant"
"github.com/gin-gonic/gin"
)

// VisitAuth when user visit the site image, check visit token. This only for private mode.
func (am *AuthUserMiddleware) VisitAuth() gin.HandlerFunc {
return func(ctx *gin.Context) {
if len(os.Getenv("SKIP_FILE_ACCESS_VERIFY")) > 0 {
ctx.Next()
return
}
// If visit brand image, no need to check visit token. Because the brand image is public.
if strings.HasPrefix(ctx.Request.URL.Path, "/uploads/branding/") {
ctx.Next()
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/user_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,5 +726,5 @@ func (uc *UserController) setVisitCookies(ctx *gin.Context, visitToken string, f
return
}
ctx.SetCookie(constant.UserVisitCookiesCacheKey,
visitToken, constant.UserVisitCacheTime, "/", parsedURL.Host, true, true)
visitToken, constant.UserVisitCacheTime, "/", parsedURL.Hostname(), true, true)
}

0 comments on commit dae16c6

Please sign in to comment.