Alright, let's say that I have a Policy with the class name 'AccessGroupPolicy' that that has a view method as follows:
public function view(Group $group)
{
dd('This should be Running');
return 1;
}
Which I have registered in the AuthServiceProvider as the following:
protected $policies = [
Group::class => AccessGroupPolicy::class,
];
(Note: I do not have my Models in the App\ namespace as this was originally a 4.0 application, never migrated them into the App\ namespace).
Then, I call this authorization as a Middleware one of my Controllers as follows:
public function __construct() {
$this->middleware('can:view,group');
}
I am finding that, for whatever reason, the Policy that I registered never actually runs (I added the dd to check that), and instead this always throws a 403. I do know that the group model is being injected correctly, as once in the controller, I'm able to work with it. Any idea what is going on? I'm running Laravel 5.4, and the users are logged in via Passport (OAuth2).
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire