Laravel 5.5 ACL issue and quick fix
While working with laravel 5.5 encountered a strange issue. The authorization policy was never triggered and it always says unauthorized. I’ve gone through every recommendation but couldn’t find a fix. Finally after some trail and error tricks found the issue.
In the policies array of AuthServiceProvider, use only short notation of class like below.
protected $policies = [
Organization::class => OrganizationPolicy::class
];
Instead of writing the full class names here, import them like
use App\CRUDModels\Organization; use App\Policies\OrganizationPolicy;
I faced the issue when the code was like this
protected $policies = [
App\CRUDModels\Organization::class => App\Policies\OrganizationPolicy::class
];
I am currently not sure why it worked but it certainly works.