UserPolicy is called for viewNova gate #5971
Replies: 2 comments
-
|
Wouldn't this cause a breaking change if users already utilize Also note that this usage is identical to other first-party packages: https://github.com/laravel/telescope/blob/3a250a44faa89ba4790ad6207060e90f79f49d1e/src/TelescopeApplicationServiceProvider.php#L29-L32 |
Beta Was this translation helpful? Give feedback.
-
|
I understand this would be a breaking change for anyone relying on For clarity I would propose to add some information to https://nova.laravel.com/docs/installation.html#authorizing-access-to-nova so developers are aware of this behaviour. Some sentence like:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
As already stated in #2795 currently the
Gate::check('viewNova', [Nova::user($request)])call in theNovaApplicationServiceProvider::authorization()call leads to unintended behaviour regarding the use of Policies.By passing
[Nova::user($request)]to the gate method, Laravel authorization logic resolves to the existing UserPolicy.As stated in the Laravel Docs:
As @crynobone stated in #2795 (comment) the parameter is used for assuring that the correct guard is used.
I don't see how by passing the parameter you are assuring this.
Could you please lead me to the code for better understanding?
In https://laravel.com/docs/10.x/authorization#authorizing-actions-via-gates there is mentioned another method for specific user checking:
Gate::forUserWould this be a better approach?
The default authorization code would then be:
and this should assure that there is no interference with the UserPolicy in any unintended way.
Detailed steps to reproduce the issue on a fresh Nova installation:
public function __callorpublic function viewNovaBeta Was this translation helpful? Give feedback.
All reactions