From 802c2550bc79e6ad59c99dfa559d9e5e61a78196 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 22 Jul 2021 09:48:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E4=B8=AD=E9=97=B4=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Middleware/AuthApi.php | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 app/Http/Middleware/AuthApi.php diff --git a/app/Http/Middleware/AuthApi.php b/app/Http/Middleware/AuthApi.php new file mode 100644 index 0000000..c49da1e --- /dev/null +++ b/app/Http/Middleware/AuthApi.php @@ -0,0 +1,49 @@ +header('Authentication'); + $appid = $request->header('appid'); + if (!$auth || !$appid) { + return response()->json([ + 'code' => -1, + 'msg' => 'header参数缺失', + 'data' => [], + 'status' => '500', + ]); + } + // TODO 登录部分待优化 + if (!Cache::get($auth)) { + return response()->json([ + 'code' => -1, + 'msg' => '请先登录', + 'data' => [], + 'status' => '500', + ]); + } + if (!Cache::get($appid)) { + return response()->json([ + 'code' => -1, + 'msg' => 'lose appid', + 'data' => [], + 'status' => '500', + ]); + } + return $next($request); + } +}