Laravel two diffrent middleware authentication from auth middleware only

℡╲_俬逩灬. 提交于 2019-12-11 18:34:21

问题


I have two seprate table for authentication. Following middleware pointing to different table:

$this->middleware('auth:admin'); // - admins 
$this->middleware('auth'); // - user

The solution i need :

  • 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?


回答1:


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.



来源:https://stackoverflow.com/questions/52115674/laravel-two-diffrent-middleware-authentication-from-auth-middleware-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!