Laravel 4 with Sentry 2 for ACL Note: I am using laravel functions for login, but need sentry only for ACL purpose, to check permissions
Want to achieve this:
if ( Sentry::getUser()->hasAnyAccess(['system']) )
{
echo 'has access to system';
}
but i keep getting the following error:
Sentry::getUser()->hasAnyAccess(['system']); //this hits error: Call to a member function hasAnyAccess() on a non-object
The way Sentry2 does authentication is not compatible with Laravel's built in authentication system. As far as I understand Laravel's built in authentication system and Sentry2 set different session keys to store the details of the logged in user. So it is not possible to use Sentry2 to pull up the details about laravel authenticated user. But, given that you use the same database table for both
User
model and the model used with Sentry2 this should work.If you want to use Sentry in built in auth compatible way you may want to check this package.
https://bitbucket.org/hampel/sentry-auth-driver-for-laravel