默认身份验证
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
身份验证防护
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'jwt',
'provider' => 'users',
'hash' => false,
],
'student' => [
'driver' => 'session',
'provider' => 'students',
]
],
用户提供商
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'students' => [
'driver' => 'eloquent',
'model' => App\Student::class,
]
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
当我尝试使用学生表username
登录时,password
不会登录,但是当我更改
向学生认证默认值
'defaults' => [
'guard' => 'api',
'passwords' => 'students',
],
和提供给学生的api
'api' => [
'driver' => 'jwt',
'provider' => 'users',
'hash' => false,
],
使用学生表数据登录,但用户表数据不允许登录。
如何实现这两个用户表进行登录?
预先感谢
答案 0 :(得分:0)
您应将防护名称传递给auth函数:
auth('students')->login();
或
Auth::guard('students')->login()
或通过将默认防护传递给auth中间件来覆盖默认防护:
Route::group(['middleware' => ['auth:students'] ], function(){
//your routes here
});