Abilities (Brezel 3.x)
Abilities
Section titled “Abilities”Abilities are permissions that are not tied to a module, for example whether users may use API keys. Like module permissions, they are granted per role and are off by default.
| Ability | Grants |
|---|---|
api_keys | Creating, reactivating and authenticating with API keys |
Set them in the abilities field of a role:
[{ "resource_entity": "integration_role", "resource": { "module": "roles", "fields": { "name": "Integration", "slug": "integration", "abilities": { "api_keys": true }, "modules": false } }}]A role has an ability if it sets it to true, if it has full access ("modules": true), or if one of its parent roles has it.
Root users have all abilities.
Editing abilities in the UI
Section titled “Editing abilities in the UI”The permissions widget shows the abilities of a role above the module matrix.
To make them editable, add an abilities field to your roles module, just like the modules field:
[{ "resource_module": "roles", "resource": { "identifier": "roles", "type": "roles", "title": "name", "fields": [ { "identifier": "name" }, { "identifier": "slug" }, { "identifier": "modules", "type": "code" }, { "identifier": "abilities", "type": "code" } ] }}]Without this field, the abilities are shown read-only.
Custom abilities
Section titled “Custom abilities”You can declare your own abilities with the abilities option of that field.
They behave exactly like built-in ones and appear in the permissions widget:
{ "identifier": "abilities", "type": "code", "options": { "abilities": ["export_pdf", "see_purchase_prices"] }}Labels are taken from the translation modules.<roles module>.abilities.<name>, e.g. modules.roles.abilities.export_pdf.
Check abilities with the hasAbility recipe function, e.g. to hide a button:
{ "type": "buttons", "options": {"buttons": [{"title":"Export PDF","identifier":"export_pdf","options":{"recipes":{"display":"hasAbility('export_pdf')"}}}]}}