Laravel角色和认证路线 [英] Laravel Roles and authentication to routes

查看:185
本文介绍了Laravel角色和认证路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待存档以下

在Userlogs - >分配从DB特权 - >他们只能看到允许路由仅

Userlogs in -> Assigned a privilege from the DB -> They can only see allowed routes only

到目前为止,我已经能够到达这里:

So far i have been able to reach here:

$user = Usercredential::where('username','=',Auth::user()->username)->get();

foreach ($user as $u ) {

        $status = $u->userstatus;
        $userPriv = $u->userpriviledge;

        if ($status == 0){  
                           Session::put('user_priv',$userPriv);
            }
        else{
                    return Redirect::to_route('home')->with('message','Inactive users cannot login');
            }

这将检查用户的状态,如果活动或不活动,然后保存在我的会议的特权。接下来是什么?如何保护我的路线?

Which checks the status of the user if active or inactive then stores the priviledge in my session. What next? How do i protect my routes?

感谢

推荐答案

对于那些在未来谁正在寻找这种解决方案

For those in the future who are looking for this solution

<一个href=\"http://net.tutsplus.com/tutorials/php/build-web-apps-from-scratch-with-laravel-filters-validations-and-files/\" rel=\"nofollow\">http://net.tutsplus.com/tutorials/php/build-web-apps-from-scratch-with-laravel-filters-validations-and-files/

会有很大的帮助,感谢Rodri您的指针。
我AP preciate。

Will be very helpful, thanks Rodri for your pointer. I appreciate.

这篇关于Laravel角色和认证路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆