user(); $clientRoute = request()->route()->getName(); if (!empty($user)) MenuServer::creatServer()->sendMenu($user->{'roles_id'}); if (in_array($clientRoute, ['login','logout', 'admin.index.ajax', 'admin.not.permission', 'admin.index', 'admin.ajaxIndex', 'admin.switch', 'admin.u_sort'])) { return $next($request); } $ret = PermissionServer::verifyPermission($user->{'roles_id'}, $clientRoute); if (empty($ret) && $user->{'id'} != 1) { $is_ajax = request()->ajax(); if ($is_ajax) { return response()->json([ 'status' => 'error', 'message' => '暂无权限', 'redirect' => '', 'callback' => '', 'data' => [] ]); } else { // 当前会员没有权限 return redirect()->route('admin.not.permission'); } } return $next($request); } }