Laravel 5.2 多 Table AuthManager.php 中的身份验证错误异常
Laravel 5.2 Multi Table Authentication ErrorException in AuthManager.php
我使用 Laravel 5.2 并且我需要使用多重 table 身份验证。我读到这个 link
我修改了config/auth.php
'guards' => [
'user' =>[
'driver' => 'session',
'provider' => 'user',
],
'admin' => [
'driver' => 'session',
'provider' => 'admin',
],
],
//User Providers
'providers' => [
'user' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admin' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
]
],
//Resetting Password
'passwords' => [
'user' => [
'provider' => 'user',
'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 60,
],
'admin' => [
'provider' => 'admin',
'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 60,
],
],
这是登录控制器的一部分(post方法)
$admindata = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
if (Auth::attempt($admindata)) {
echo 'SUCCESS!';
} else {
$admin = Auth::admin();
return Redirect::to('/b');
}
但是我遇到了这个错误
ErrorException in AuthManager.php line 288: call_user_func_array()
expects parameter 1 to be a valid callback, class
'Illuminate\Auth\SessionGuard' does not have a method 'admin'
看来错误是在 Auth::attempt()
上。如何解决这个错误?
我相信错误不在 attempt
方法中,而是在此处:
$admin = Auth::admin();
你试试运行这里的admin
方法,显然Illuminate\Auth\SessionGuard
class.
中没有这样的方法
我使用 Laravel 5.2 并且我需要使用多重 table 身份验证。我读到这个 link
我修改了config/auth.php
'guards' => [
'user' =>[
'driver' => 'session',
'provider' => 'user',
],
'admin' => [
'driver' => 'session',
'provider' => 'admin',
],
],
//User Providers
'providers' => [
'user' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admin' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
]
],
//Resetting Password
'passwords' => [
'user' => [
'provider' => 'user',
'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 60,
],
'admin' => [
'provider' => 'admin',
'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 60,
],
],
这是登录控制器的一部分(post方法)
$admindata = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
if (Auth::attempt($admindata)) {
echo 'SUCCESS!';
} else {
$admin = Auth::admin();
return Redirect::to('/b');
}
但是我遇到了这个错误
ErrorException in AuthManager.php line 288: call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Auth\SessionGuard' does not have a method 'admin'
看来错误是在 Auth::attempt()
上。如何解决这个错误?
我相信错误不在 attempt
方法中,而是在此处:
$admin = Auth::admin();
你试试运行这里的admin
方法,显然Illuminate\Auth\SessionGuard
class.