Skip to content

Commit

Permalink
Clarify that "super" access requires using Laravel Gate methods
Browse files Browse the repository at this point in the history
  • Loading branch information
drbyte authored Aug 30, 2024
1 parent 631799b commit fe70ca8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/basic-usage/super-admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ We strongly recommend that a Super-Admin be handled by setting a global `Gate::b

Then you can implement the best-practice of primarily using permission-based controls (@can and $user->can, etc) throughout your app, without always having to check for "is this a super-admin" everywhere. **Best not to use role-checking (ie: `hasRole`) (except here in Gate/Policy rules) when you have Super Admin features like this.**

NOTE: Using this approach, you can/must call Laravel's standard `can()`, `canAny()`, `cannot()`, etc checks for permission authorization to get a correct Super response. Calls which bypass Laravel's Gate (such as a direct call to `->hasPermissionTo()`) will not go through the Gate, and will not get the Super response.


## `Gate::before`
If you want a "Super Admin" role to respond `true` to all permissions, without needing to assign all those permissions to a role, you can use [Laravel's `Gate::before()` method](https://laravel.com/docs/master/authorization#intercepting-gate-checks). For example:
Expand Down

0 comments on commit fe70ca8

Please sign in to comment.