Organisation Permissions
Intro
The Organisation Permission Model is set up to allow specific permission management and tracking to users within an organisation. These permissions globally managed in the OrganisationPermissions enum and then seeded into the organisation_permissions table via the ProductionSeeder
Global Organisation Permissions
Backend
As mentioned, the organisations permissions globally managed in the OrganisationPermissions enum. If a new permission needs to be added, it can be added to the enum. Once added you can run the ProductionSeeder to seed the permission to the database.
Frontend
When adding a permission to the backend, you can make it available on the front-end by adding to the OrganisationPermissions type declaration in the types.ts file
Managing organisation member permissions
In the front-end organisation permissions area, an user who is marked as an owner or has the edit-permissions permission can change organisation member permissions.
Determining user permissions
Backend
In the backend, you can use the User model method hasOrganisationPermission($organisation, $permission) to determine if a user has a certain permission
$user->hasOrganisationPermission($organisation, OrganisationPermissions::EDIT_PERMISSIONS->value);
Frontend
In the front-end, all the user permissions are saved to the global store method currentOrgUserCan, and you can determine if a user has a certain premission by checking if it includes the permission name:
store.currentOrgUserCan(OrganisationPermissions.EDIT_PERMISSIONS);