feat(visit): can visit branding image without token

This commit is contained in:
LinkinStars 2023-10-10 17:49:20 +08:00
parent c2b4a49dc0
commit a0d57a1890
1 changed files with 7 additions and 0 deletions

View File

@ -4,11 +4,18 @@ import (
"github.com/answerdev/answer/internal/base/constant"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
// 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 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()
return
}
siteLogin, err := am.siteInfoCommonService.GetSiteLogin(ctx)
if err != nil {
return