header('Authentication'); if (empty($auth)) { return response()->json([ 'code' => -1, 'msg' => '关键认证参数缺失', 'data' => [], 'status' => 500, ]); } //检查用户 TODO 登录部分待优化 $user_id = Cache::get($auth); if (empty($user_id) || $user_id != User::query()->where(['id' => $user_id, 'status' => 1])->value('id')) { return response()->json([ 'code' => -2, 'msg' => '用户不存在或登录已超时,请重新登录', 'data' => [], 'status' => 403, ]); } return $next($request); } }