Laravel仅来自身份验证中间件的两个不同的中间件身份验证
问题描述:
我有两个单独的表进行身份验证.以下中间件指向不同的表:
I have two seprate table for authentication. Following middleware pointing to different table:
$this->middleware('auth:admin'); // - admins
$this->middleware('auth'); // - user
我需要的解决方案:
- 我希望仅通过两个不同的表来完成身份验证
"
$this->middleware('auth')
"中间件 - 通过中间件"
$this->middleware('auth')
"我要同时登录 管理员和用户.当前管理员和用户从diffrent登录 我在上面显示的中间件.
- I want authentication must be done with two diffrent table through only
"
$this->middleware('auth')
" middleware - Through middleware "
$this->middleware('auth')
" I want to login both admin and user. Currently admin and user login from diffrent middleware I have shown above.
为此,我需要在项目文件夹中的哪个文件中以及哪个位置进行更改?
For this, in which file and where I need to change in my project folder?
答
如果要同时检查两个守卫",则可以将多个守卫传递给auth
中间件.
If you want to have both "guards" be checked you can just pass multiple guards to the auth
middleware.
$this->middleware('auth:web,admin');
这将旋转经过的守卫,如果其中任何一个产生用户,它将把该守卫设置为默认前进.
This will spin through the guards passed and if any of them produce a user it will set that guard as the default moving forward.