samedi 5 décembre 2015

laravel 5.1 authentication - cannot redirect to login page

trying to block a route for the guest users. when someone hits localhost:8000/AdminPanel it will check if the user is logged in as an admin or not. if admin then it works fine, if an agent then it redirects to the login page but if i hit the link as a guest user, it doesnt redirect me to the login page instead it shows some error--> ErrorException in routes.php line 53: Trying to get property of non-object. please correct me. here is my routes.php file:

     Route::get('/AdminPanel', function () {

            if(Auth::user()->user_type_id==1){    //line 53
                return view('frontend.AdminPanel');       
            }
            if(Auth::user()->user_type_id==2){
                return view('auth/login');
            }
            if(Auth::guest()){
                return view('auth/login');
            }

        });



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire