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); + } +}