diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index a0069bc..d2b2fd7 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -17,13 +17,11 @@ class Controller extends BaseController public function __construct() { -// Cache::put('wx0e8ebcd9ca9e4b97', 1); -// Cache::put('c4ca4238a0b923820dcc509a6f75849b', 1); // TODO 登录部分待优化 $auth = request()->header('Authentication'); $appid = request()->header('appid'); - //代理商和用户已经在中间件中检查过了,这里不再重复检查,也避免后台出错 + //代理商和用户已经在ApiBase和ApiAuth中间件中检查过了,这里不再重复检查,也避免后台出错 if ($auth) { $this->user_id = Cache::get($auth); } diff --git a/app/Http/Middleware/ApiBase.php b/app/Http/Middleware/ApiBase.php index 3221eaf..f695646 100644 --- a/app/Http/Middleware/ApiBase.php +++ b/app/Http/Middleware/ApiBase.php @@ -22,8 +22,8 @@ class ApiBase } //检查代理商 - $agent_id = Cache::get($appid); - if (empty($agent_id) || $agent_id != Agent::query()->where(['appid' => $appid, 'status' => 1])->value('id')) { + $agent_id = Agent::query()->where(['appid' => $appid, 'status' => 1])->value('id'); + if (empty($agent_id)) { return response()->json([ 'code' => -1, 'msg' => '商户不存在或已被禁用',