|
@@ -37,14 +37,22 @@ func Auth(settingObj cfacade.ProfileJSON) gin.HandlerFunc {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- // 获取请求URL
|
|
|
|
- // url := c.Request.URL.Path
|
|
|
|
- // s, err := mdb.RDB.HGet(context.Background(), common.GetTokenKey(tokenString), url).Result()
|
|
|
|
- // if err != nil {
|
|
|
|
- // mhayaLogger.Warnf("Auth HGet s error: %s", err.Error())
|
|
|
|
- // common.PackUnauthorizedResult(c, code.InternalError, "")
|
|
|
|
- // return
|
|
|
|
- // }
|
|
|
|
|
|
+ if result != constant.AdminAccess {
|
|
|
|
+ // 获取请求URL
|
|
|
|
+ url := c.Request.URL.Path
|
|
|
|
+ s, err := mdb.RDB.HGet(context.Background(), common.GetTokenKey(tokenString), url).Result()
|
|
|
|
+ if err != nil {
|
|
|
|
+ mhayaLogger.Warnf("Auth HGet s error: %s", err.Error())
|
|
|
|
+ common.PackUnauthorizedResult(c, code.InternalError, "")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 检查是否有权限
|
|
|
|
+ if s == "" {
|
|
|
|
+ common.PackUnauthorizedResult(c, code.UnauthorizedError, "token is no auth")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
ss, err := mdb.RDB.HGet(context.Background(), common.GetTokenKey(tokenString), constant.AdminAccess).Result()
|
|
ss, err := mdb.RDB.HGet(context.Background(), common.GetTokenKey(tokenString), constant.AdminAccess).Result()
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -54,7 +62,7 @@ func Auth(settingObj cfacade.ProfileJSON) gin.HandlerFunc {
|
|
}
|
|
}
|
|
|
|
|
|
// 检查是否有权限
|
|
// 检查是否有权限
|
|
- if ss == "" && result == "" {
|
|
|
|
|
|
+ if ss == "" {
|
|
common.PackUnauthorizedResult(c, code.UnauthorizedError, "token is no auth")
|
|
common.PackUnauthorizedResult(c, code.UnauthorizedError, "token is no auth")
|
|
return
|
|
return
|
|
}
|
|
}
|