Resource policies / can
The filament base resource has the static
can
method, which looks like:
I don't get the point from the last row. When already having the $policy
and making sure, there is a method $action
, why not just
or what is the difference? In my current case, "my" line returns true, while Gate::forUser($user)->check($action, $record ?? $model)
returns false. Is it possible, that it ignores the used guard?13 Replies
because the gate allows policy overrides etc
wdym by "ignores the used guard"
i think its bad practice to call policy methods directly when theres a Laravel method to do it for us
Thanks for explanation, But then I don't get it, why my user doesn't have access to my resource.
This is the Policy:
to test it, I tried it (directly in the
can
method of the resource class):
first returns true, second falseis your policy registered?
Inside AuthSeriveProvider
not sure then
but it must be a laravel issue, right?
you should debug inside the check() method in /vendor
yeah, I tried that already:
but I understand, that you cant give "support" for such issues. Just thought it is a stupid mistake from myself 😄
whats use_filament
a permission I check inside
public function canAccessFilament(): bool
but this is ok, its trueif you just return true from viewAny directly what happens
which
viewAny
?the one that calls the other gate method
in your policy
it looks like it is never called, dd in the ArticlePolicy doesn't get printed
To resolve the mystery: I am once again stupid.
I had this in my AuthServiceProvider:
And since this is (for this user) alway false,.....
Thanks for your time
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View