Comments (6)
Intercept the created event in the Permission model and attach the created permission to the superadmin role.
from laratrust.
I don't think this quite suffices as a proper solution to this problem. It sounds more like a workaround than a proper solution.
(Thank you for your response anyway, I appreciate the effort)
from laratrust.
Without modifing Laratrust behaviour there are only 2 ways to do what you need.
The first one is to keep the SuperAdmin role permissions in sync with all the available permissions (see above for the implementation)
The second one is to add a check for the SuperAdmin role everytime you check for permissions (ie. if the user has this permission OR he has the SuperAdmin role).
Otherwise, you have to change the Laratrust behaviour to check for the single permission OR check for the SuperAdmin role.
From my point of view, the first solution is the easiest and cleanest of all of them.
from laratrust.
I am not entirely sure if this would work, but after some digging, perhaps it'd be possible to override the hasPermission
method on my User
class that implements the LaratrustUserTrait
?
Wouldn't that hide away the trait's method for my own implementation? Since class methods take precedence over trait methods.
Correct me if I'm wrong of course, but isn't that a possible solution?
from laratrust.
How I've made it in the past is by defining one permission that only super admins have and in side the policies i check if the user has that permission or the actually required permission. or by simply adding all the permissions to the admin.
from laratrust.
even though it's not exactly the solution I was looking for, it is a better solution than what was proposed before, in my honest opinion. Thank you both for your help. I'll propose this change internally.
from laratrust.
Related Issues (20)
- Objects Ownership HOT 1
- Setting the permissions_as_gates with teams enabled breaks the `can` method in routes. HOT 2
- Upgrade from 7.x to 8.x documentation missing relationship queries HOT 2
- isAbleTo function is very slow HOT 6
- Errror: Index name is too long. HOT 1
- Dynamic Routing HOT 4
- Deprecation warning, passing null to str_contains() - Middleware Permission HOT 1
- INFO No publishable resources for tag ["laratrust"]. HOT 2
- Able to click to copy command line for package installation and configuration. HOT 1
- Disable all user to see Administration Panel
- Permission name unique validation against 'roles' table HOT 1
- Mobile device or small display top nav bar collapse not working
- Support for Laravel 11 HOT 3
- Schema is not imported
- Cannot use @permission and @ability in blade template Laravel 11 HOT 1
- Possible error in documentation HOT 1
- The ownership was removed. HOT 1
- Error on delete Role
- Trait "Laratrust\Traits\LaratrustUserTrait" not found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laratrust.