Is it possible to define roles and permissions purely in code instead of in the database? #2565
Replies: 1 comment 2 replies
-
If you provide no UI to users for changing/setting permissions/roles, then all your roles and permissions ARE "in code", even if their state is set within the database. You would manage all of it via migrations that add/remove/assign permissions/roles. But if you're wanting to skip the database entirely, then this package is not suitable for that situation. You would have to write code inside your User model (or other model) to check whether a user (who IS in the database) has permission to do a certain action, such as with functions like " Before using a package like this one, most people would simply add a couple boolean fields to the User table in the db for certain permissions, and just check against those, as explained above. If that's all you require, then you don't need any package at all. |
Beta Was this translation helpful? Give feedback.
-
For the particular project I want to use this for I do not want the user to be able to edit roles and permissions. This means that using the database for these roles and permissions would come with more headaches to ensure that the application will always have up-to-date roles and permissions.
Of course I could use something like https://github.com/ryangjchandler/orbit as well but I'd prefer to not need an extra package for this. Is such a thing possible in a clean way?
Beta Was this translation helpful? Give feedback.
All reactions