权限检查修改返回结构名称,修复前端无限循环getinfo接口bug
This commit is contained in:
1 parent
02f46de17c
commit
bf494c2131
1 file changed
+4
-4
@@ -16,19 +16,19 @@ func AuthCheckRole() gin.HandlerFunc {
|
|||||||
data, _ := c.Get("JWT_PAYLOAD")
|
data, _ := c.Get("JWT_PAYLOAD")
|
||||||
v := data.(jwtauth.MapClaims)
|
v := data.(jwtauth.MapClaims)
|
||||||
e, err := mycasbin.Casbin()
|
e, err := mycasbin.Casbin()
|
||||||
tools.HasError(err,"",500)
|
tools.HasError(err, "", 500)
|
||||||
//检查权限
|
//检查权限
|
||||||
res, err := e.Enforce(v["rolekey"], c.Request.URL.Path, c.Request.Method)
|
res, err := e.Enforce(v["rolekey"], c.Request.URL.Path, c.Request.Method)
|
||||||
log.Println("----------------", v["rolekey"], c.Request.URL.Path, c.Request.Method)
|
log.Println("----------------", v["rolekey"], c.Request.URL.Path, c.Request.Method)
|
||||||
|
|
||||||
tools.HasError(err,"",500)
|
tools.HasError(err, "", 500)
|
||||||
|
|
||||||
if res {
|
if res {
|
||||||
c.Next()
|
c.Next()
|
||||||
} else {
|
} else {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"status": 401,
|
"code": 401,
|
||||||
"msg": "对不起,您没有该接口访问权限,请联系管理员",
|
"msg": "对不起,您没有该接口访问权限,请联系管理员",
|
||||||
})
|
})
|
||||||
c.Abort()
|
c.Abort()
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in new issue
Block a user