123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- use Illuminate\Auth\AuthenticationException;
- use Illuminate\Auth\Middleware\Authenticate;
- use Illuminate\Support\Facades\Auth;
- //use Illuminate\Contracts\Auth\Factory as Auth;
- class AdminAuthenticate
- {
- /**
- * The authentication factory instance.
- *
- * @var \Illuminate\Contracts\Auth\Factory
- */
- protected $auth;
- /**
- * Create a new middleware instance.
- *
- * @param \Illuminate\Contracts\Auth\Factory $auth
- * @return void
- */
- public function __construct(Auth $auth)
- {
- $this->auth = $auth;
- }
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @param string[] ...$guards
- * @return mixed
- *
- * @throws \Illuminate\Auth\AuthenticationException
- */
- public function handle($request, Closure $next, ...$guards)
- {
- if (!Auth::guard('admin')->check()) {
- return redirect('/admin/login');
- }
- return $next($request);
- }
- }
|