| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace app\v1\middleware;
- use plugin\saiadmin\app\cache\UserInfoCache;
- use Webman\Http\Request;
- use Webman\Http\Response;
- use Webman\MiddlewareInterface;
- /**
- * 权限检查中间件
- */
- class FilterPermission implements MiddlewareInterface
- {
- public function process(Request $request, callable $handler) : Response
- {
- // 根据用户id获取用户权限
- $token = getCurrentInfo();
- // 用户权限缓存
- $userAuthCache = new UserInfoCache($token['id']);
- $user_info = $userAuthCache->getUserInfo();
- // 获取游戏数据权限
- $auth_game_list = $user_info['game_list'] ?? -1;
- // 获取游戏自然量数据权限
- $auth_normal_game_list = $user_info['normal_game_list'] ?? -1;
- // 获取游戏自然量数据权限
- $auth_ad_permission = $user_info['ad_permission'] ?? -1;
- $request->setGet(['auth_normal_game_list' => $auth_normal_game_list==='*'?'':$auth_normal_game_list,'auth_game_list' => $auth_game_list==='*'?'':$auth_game_list,'auth_ad_permission' => $auth_ad_permission==='*'?'':$auth_ad_permission]);
-
- return $handler($request);
- }
- }
|