123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- use Dcat\Admin\Admin;
- use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
- class DistAuth
- {
- private $excludeList = [
- '/auth/users',
- '/auth/roles',
- '/auth/permissions',
- '/auth/menu',
- '/auth/extensions',
- '/helpers/scaffold',
- '/helpers/icons',
- ];
- public function handle($request, Closure $next)
- {
-
- foreach ($this->excludeList as $item) {
- if (strpos($request->url(), $item) !== false) {
- if (!Admin::user()->isAdministrator()) {
- throw new NotFoundHttpException;
- }
- }
- }
-
- return $next($request);
- }
- }
|