123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?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;
- }
- }
- }
-
- if (Admin::user()) {
- if (!getDistributor()) {
- if (strpos($request->url(), 'auth/logout') == false) {
-
- return redirect('/dist/auth/logout');
- }
- }
- }
-
- return $next($request);
- }
- }
|