Zizaco / entrust

Role-based Permissions for Laravel 5
MIT License
6.05k stars 1.29k forks source link

A problem with route null/redirection #79

Open haltsir opened 10 years ago

haltsir commented 10 years ago

When I use this:

Entrust::routeNeedsPermission('admin/roles*', 'config_manage');

I get an HttpException and 500 Internal Server Error. When I use this:

Entrust::routeNeedsPermission('admin/roles*', 'config_manage', Redirect::to('admin')->with('message', array( 'type' => 'warning', 'content' => 'No permissions for this resource' )));

then the flash message appears on every click on the website.

I'm using Laravel 4.0 with the latest updates.

toonzone commented 10 years ago

Hi, How did you solve this problem?

I have the exact same problem too!!!

haltsir commented 10 years ago

I end up using this:

Route::filter('manage_config', function() { if (!Entrust::can('manage_config')) { return Redirect::to('admin')->with('message', array( 'type' => 'warning', 'content' => 'No permissions for this resource.' )); } }); Route::when('admin/roles*', 'manage_config');