简体   繁体   English

根据用户角色和状态在laravel中登录

[英]Login in laravel based on role and status of a user

I'm using laravel Auth() method for login a user. 我正在使用laravel Auth()方法登录用户。 How can I redirect a particular user to admin/dashbord page, if he has 'role=1' and rediect a user to user/home page if he has 'role=2'? 如果特定用户的角色为“ role = 1”,如何将其重定向到管理员/仪表板页面;如果特定用户的角色为“ role = 2”,则如何将其重新定向至用户/主页?

And how can I prevent an user login, if his status is blocked ( status=0 )? 如果用户的状态被阻止( status=0 ),如何防止用户登录?

My user table structure is showing below. 我的用户表结构如下所示。 Role and status are two columns in my table. 角色和状态是我表中的两列。

在此处输入图片说明

Check out this lesson on Laracasts, Users and Roles , which has this source code . 查看有关Laracast, 用户和角色的课程,该课程具有此源代码

If you don't want to roll your own, you might want to look into Entrust . 如果您不想自己动手,则可能需要研究Entrust

If you'd like more of a coded answer, please include code to reference. 如果您想获得更多的编码答案,请附上代码以供参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM