feat : 没有权限的接口使用log输出

This commit is contained in:
zhangwenjian
2021-01-12 13:22:03 +08:00
parent 305326d9ea
commit f768d69def
+4 -1
View File
@@ -28,14 +28,17 @@ func AuthCheckRole() gin.HandlerFunc {
} else {
res, err = e.Enforce(v["rolekey"], c.Request.URL.Path, c.Request.Method)
if err != nil {
log.Errorf("msgID[%s] error:%s method:%s path:%s", msgID, err, c.Request.Method, c.Request.URL.Path)
log.Errorf("msgID[%s] AuthCheckRole error:%s method:%s path:%s", msgID, err, c.Request.Method, c.Request.URL.Path)
app.Error(c, 500, err, "")
return
}
}
if res {
log.Infof("msgID[%s] isTrue: %v role: %s method: %s path: %s", msgID, res, v["rolekey"], c.Request.Method, c.Request.URL.Path)
c.Next()
} else {
log.Warnf("msgID[%s] isTrue: %v role: %s method: %s path: %s message: %s", msgID, res, v["rolekey"], c.Request.Method, c.Request.URL.Path,"当前请求是没有接口权限的,请管理员确认!")
c.JSON(http.StatusOK, gin.H{
"code": 403,
"msg": "对不起,您没有该接口访问权限,请联系管理员",