appType(AppTypeDict::API); //检测站点 ( new AuthService() )->checkSite($request); //通过配置来设置系统header参数 try { $token = $request->apiToken(); $token_info = ( new LoginService() )->parseToken($token); } catch (AuthException $e) { //是否将登录错误抛出 if ($is_throw_exception) return fail($e->getMessage(), [], $e->getCode()); } if (!empty($token_info)) { $request->memberId($token_info[ 'member_id' ]); } //校验会员和站点 ( new AuthService() )->checkSiteAuth($request); return $next($request); } }