Quick Start
Getting started with Puedo
Installation
Usage
Define Permissions
Let's pretend our app is a CRM, and there is a button that should displayed conditionally within the header in users page.
We just defined a nested permission structure and set the default visibility to false.
Define Roles
Let's say we have a role called admin and a role called user.
Giving Permissions to Roles
We want to give admin the permission to see the button, and user the permission to not see the button.
Since we defined the default visibility to false, we need to explicitly give the permission to admin but not to user.
Let's update the permissions for the admin role.
Initialize Puedo
We need to initialize Puedo with the roles and permissions we defined.
Puedo is a class that takes a configuration object with the following properties:
accessorKey: The key of the accessor field in the user object.permissions: The permissions array.roles: The roles array.
Using Puedo
Now we can use Puedo to check if a user has a permission.