handle
中间件中的RedirectIfAuthenticated
函数始终返回防护“ admin”。
RedirectIfAuthenticated
class RedirectIfAuthenticated
{
public function handle($request, Closure $next, $guard = null)
{
print_r($guard);
// if ($guard == "web" && Auth::guard($guard)->check()) {
// return redirect('/home');
// }
// if ($guard == "manager" && Auth::guard($guard)->check()) {
// return redirect('/manager');
// }
// if ($guard == "admin" && Auth::guard($guard)->check()) {
// return redirect('/admin');
// }
return $next($request);
}
}
config / auth.php
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'employees',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'employees',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
'manager' => [
'driver' => 'session',
'provider' => 'managers',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
],
'providers' => [
'employees' => [
'driver' => 'eloquent',
'model' => App\Employee::class,
],
'managers' => [
'driver' => 'eloquent',
'model' => App\Manager::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
'passwords' => [
'employees' => [
'provider' => 'employees',
'table' => 'password_resets',
'expire' => 60,
],
'managers' => [
'provider' => 'managers',
'table' => 'password_resets',
'expire' => 60,
],
'admins' => [
'provider' => 'admins',
'table' => 'password_resets',
'expire' => 60,
],
],
];