From 41e992957adc662585d85ccd87638d2a88fd5376 Mon Sep 17 00:00:00 2001 From: liapples Date: Mon, 16 Aug 2021 10:10:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=90=86=E5=95=86?= =?UTF-8?q?=EF=BC=88=E5=95=86=E6=88=B7=E6=A3=80=E6=9F=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Controller.php | 4 +--- app/Http/Middleware/ApiBase.php | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) 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' => '商户不存在或已被禁用',