From e4a442f5606e5defd89db8c6d098855fbb161120 Mon Sep 17 00:00:00 2001 From: liapples Date: Mon, 26 Jul 2021 18:40:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=92=8C=E4=BB=A3=E7=90=86=E5=95=86=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Controller.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 827b24a..d7d8bf5 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers; +use App\Models\Agent; +use App\Models\User; use Illuminate\Support\Facades\Cache; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; @@ -20,8 +22,20 @@ class Controller extends BaseController // TODO 登录部分待优化 $auth = request()->header('Authentication'); $appid = request()->header('appid'); + + //检查用户 $this->user_id = Cache::get($auth); + $user = User::query()->firstWhere(['id' => $this->user_id, 'status' => 1]); + if (!$user) { + $this->error('用户不存在或已被禁用'); + } + + //检查代理商 $this->agent_id = Cache::get($appid); + $agent = Agent::query()->firstWhere(['id' => $this->agent_id, 'status' => 1]); + if (!$agent) { + $this->error('商户不存在或已被禁用'); + } } protected function success($data = [], $msg = 'success', $code = 0, $status = 200): array