* * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace App\Http\Middleware; use App\Repositories\Enums\ResponseCodeEnum; use Closure; /** * 检查用户是否有权限 */ class CheckUserPermissionMiddleware { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $admin = login_admin(); if (!$admin) { abort(ResponseCodeEnum::HTTP_UNAUTHORIZED, '请先登录'); } if ($admin->isSuperAdmin()) { return $next($request); } // $method = $request->method(); // $path = str_replace('/', ':', trim($request->path(), '/')); // $key = "{$method}|{$path}"; // if ($admin->can($key)) { // return $next($request); // } // abort(ResponseCodeEnum::SERVICE_NO_PERMISSION, '没有权限'); return $next($request); } }