You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a developer learning Laravel, possibly the most confusing aspects of the process so far has been Policy vs Gate handling.
Policies seem to be advertised as a system for managing authorization in a more complex way than Gates -- especially with relation to a User model's abilities with regard to another model.
However, it seems like Policies actually use Gates under the hood in a way that was very confusing for me while trying to read Auth Response objects (as per Gate::inspect() calls).
I may be fundamentally misunderstanding Laravel's logic here, but it seems to me that the Framework would greatly benefit from modifying the Illuminate\Foundation\Auth\Access\Authorizable trait (and Interface), adding a new method after (beyond can(), canAny(), cant(), and cannot()) along the lines of, say, authorize(...).
I would be very willing to submit a PR for this if it would be accepted. Something along the lines of:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
As a developer learning Laravel, possibly the most confusing aspects of the process so far has been Policy vs Gate handling.
Policies seem to be advertised as a system for managing authorization in a more complex way than Gates -- especially with relation to a User model's abilities with regard to another model.
However, it seems like Policies actually use Gates under the hood in a way that was very confusing for me while trying to read Auth Response objects (as per
Gate::inspect()
calls).I may be fundamentally misunderstanding Laravel's logic here, but it seems to me that the Framework would greatly benefit from modifying the
Illuminate\Foundation\Auth\Access\Authorizable
trait (and Interface), adding a new method after (beyondcan()
,canAny()
,cant()
, andcannot()
) along the lines of, say,authorize(...)
.I would be very willing to submit a PR for this if it would be accepted. Something along the lines of:
That can be called like
$check = $user->authorize('create', SomeClass::class, $additionalArgument);
.I would also gladly update the documentation during this.
Is this something that would help the Laravel community?
Beta Was this translation helpful? Give feedback.
All reactions