2

次のアーカイブを探しています

ユーザーログイン -> DB から権限を割り当て -> 許可されたルートのみを表示

これまでのところ、私はここに到達できました:

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

ユーザーのステータスがアクティブか非アクティブかをチェックし、権限をセッションに保存します。次は何?ルートを保護するにはどうすればよいですか?

ありがとう

4

2 に答える 2

4

ロールベースを追加する方法を提供するENTRUSTという名前の Laravel 4 パッケージをお勧めします。

于 2013-05-21T16:59:23.663 に答える
1

将来、このソリューションを探している人のために

http://net.tutsplus.com/tutorials/php/build-web-apps-from-scratch-with-laravel-filters-validations-and-files/

非常に役に立ちます。ご指摘のロドリに感謝します。感謝します。

于 2013-05-23T04:32:04.493 に答える