gpt4 book ai didi

php - Laravel 角色和路由认证

转载 作者:行者123 更新时间:2023-12-02 22:02:25 25 4
gpt4 key购买 nike

我希望归档以下内容

用户登录 -> 从数据库分配权限 -> 他们只能看到允许的路由

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

$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');
}

它检查用户的状态是活跃还是不活跃,然后将权限存储在我的 session 中。接下来是什么?我如何保护我的路线?

谢谢

最佳答案

我向您推荐名为:ENTRUST 的 Laravel 4 软件包谁提供了添加Role-based的方法

关于php - Laravel 角色和路由认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16672064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com