优化casbin接口鉴权问题,不再重复查询数据库

This commit is contained in:
linwenxiang committed 2020-09-21 11:39:19 +08:00
1 parent a06bd289b3
commit a8d5846483
4 files changed
+24 -4

No files matched your search

+1 -2
View File
@@ -16,8 +16,7 @@ func AuthCheckRole() gin.HandlerFunc {
return func(c *gin.Context) {
data, _ := c.Get(jwtauth.JwtPayloadKey)
v := data.(jwtauth.MapClaims)
e, err := mycasbin.Casbin()
tools.HasError(err, "", 500)
e := mycasbin.Casbin()
//检查权限
res, err := e.Enforce(v["rolekey"], c.Request.URL.Path, c.Request.Method)
tools.HasError(err, "", 500)