sylvainjule / kirby-bouncer

Restrict access of a user role to a specific page (and its children) in the panel.
MIT License
61 stars 6 forks source link

Better fields list declaration #2

Closed ronaldtorres closed 3 years ago

ronaldtorres commented 4 years ago

Hello, first of all, thank you for this plugin!

I think that the way as the field are declared may can be improved.

An example can be:

'sylvainjule.bouncer.list' => [
    'author' => [
        'fieldname' => 'access',
        'nav' => true
    ],
    'blog-editor' => [
        'fieldname' => 'access',
        'nav' => true
    ],
    'contributor' => [
        'fieldname' => 'access',
        'nav' => true
    ],
    'moderator' => [
        'fieldname' => 'access',
        'nav' => true
    ],
    'examplerole' => [
        'fieldname' => 'onlyAccess',
    ],
],

A more reusable way can be by adding the fields as keys and the roles inside as array|string.

Something like this:

'sylvainjule.bouncer.list' => [
    'access' => [
        'roles' => ['author', 'blog-editor', 'contributor', 'moderator'],
        'nav' => true
    ],
    'onlyAccess' => [
        'roles' => 'exampleRole',
    ],
]

Is only a suggestion šŸ™‚

EDIT: The disadvantage is when you want the same field name with different options as the nav value.

ronaldtorres commented 4 years ago

Thinking better, I know that the role is the more fastest and effective way to associate the role with the field, but i leave the issue active to know what you thinking about it. :)

sylvainjule commented 3 years ago

Thanks for the suggestion, I understand how this could be faster when you to setup a lot of roles, but also think that the current way is the most flexible one, to fine-tune specific options for each roles. So I'll keep it like this! šŸ‘€