Browse Source

Merge branch 'feature/v1.3.7' of ssh://192.168.3.207:10022/BaseService/gateway into feature/v1.3.7

wangchuanjin 2 years ago
parent
commit
c888649482
1 changed files with 5 additions and 2 deletions
  1. 5 2
      core/proxy/middleware/spiderPolyHandler.go

+ 5 - 2
core/proxy/middleware/spiderPolyHandler.go

@@ -1,6 +1,7 @@
 package middleware
 
 import (
+	"app.yhyue.com/moapp/jybase/common"
 	. "bp.jydev.jianyu360.cn/BaseService/gateway/common/gatecode"
 	"bp.jydev.jianyu360.cn/BaseService/gateway/common/httpUtil"
 	"bp.jydev.jianyu360.cn/BaseService/gateway/core/proxy/filterPoly"
@@ -27,8 +28,10 @@ func FilterPolyHandler(r *ghttp.Request) {
 	//获取策略
 	poly := filterPolyManager.GetRule(gCtx.RouterRule.LimitPloy)
 	status, key := func() (int, string) {
+		//用户身份切换
+		userFlag, _ := common.If(gCtx.Sess.MgoUserId != "", gCtx.Sess.MgoUserId, gCtx.Sess.UserId).(string)
 		if gCtx.Sess.UserId != "" && poly.Rule.BCheckId { //id请求频率校验
-			return poly.IdFilter(ctx, gCtx.Sess.UserId)
+			return poly.IdFilter(ctx, userFlag)
 		} else { //ip请求频率校验
 			return poly.IpFilter(ctx, r.GetClientIp())
 		}
@@ -57,7 +60,7 @@ func FilterPolyHandler(r *ghttp.Request) {
 	r.Middleware.Next()
 }
 
-//getVerifyPage 获取验证码页面路径
+// getVerifyPage 获取验证码页面路径
 func getVerifyPage(page string) string {
 	if page != "" {
 		if strings.HasSuffix(page, ".html") {