30 行
712 B
PHP
30 行
712 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
|
|
|
class AuthAdmin extends Middleware {
|
|
/**
|
|
* Get the path the user should be redirected to when they are not authenticated.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return string|null
|
|
*/
|
|
protected function redirectTo ($request) {
|
|
if (! $request->expectsJson()) {
|
|
return route('adminlogin');
|
|
}
|
|
}
|
|
|
|
public function handle ($request, Closure $next, $guard = null) {
|
|
if (Auth::guard($guard)->check()) {
|
|
return redirect()->intended('/home');
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|