Closed
Description
At the moment in our authorizer class we do this:
return $this->gate->check(
'view',
$model
);
An improvement would be to support Policy Responses so that the developer can return authorization messages from their policy.
To do that, the code would be something like this:
$response = $this->gate->inspect(
'view',
$model
);
if ($response->message()) {
$response->authorize();
}
return $response->allowed();
I.e. if the authorization response has a message, calling the authorize()
method on the response will throw an authorization exception with that message if the authorization has failed.