Browse Source

改为map校验

zwxi 1 year ago
parent
commit
bd5a320871
1 changed files with 6 additions and 1 deletions
  1. 6 1
      controllers/base_auth.go

+ 6 - 1
controllers/base_auth.go

@@ -206,7 +206,12 @@ func (c *BaseAuthController) Prepare() {
 				uris := strings.Split(uri,"?")
 				uri = uris[0]
 				fmt.Println("uri:",uri)
-				if !strings.Contains(api,uri) {
+				apis := strings.Split(api, "&")
+				apiMap := make(map[string]bool, 0)
+				for _, s := range apis {
+					apiMap[s] = true
+				}
+				if!apiMap[uri] {
 					c.JSON(models.BaseResponse{Ret: 403, Msg: "无权访问!", ErrMsg: "无权访问!"}, false, false)
 					c.StopRun()
 					return