Laravel仅来自身份验证中间件的两个不同的中间件身份验证 [英] Laravel two diffrent middleware authentication from auth middleware only
本文介绍了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.
这篇关于Laravel仅来自身份验证中间件的两个不同的中间件身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文