pedroborges / kirby-autogit

⬢ Saves every change made via Kirby Panel to a Git repository
149 stars 23 forks source link

Limit widget visibility to admin user role #6

Closed tobystokes closed 8 years ago

tobystokes commented 8 years ago

A small enhancement - rather than set widget on or off globally, it would be great if it could be shown to select user roles (I don't want my editors pulling and pushing!)

I have hacked a if(panel()->user()->isAdmin()) { ... around the widget for my purposes, but it would nicer if it could be specified in the config as something like c::set('autogit.widget', 'admin,other_allowed_group');

pedroborges commented 8 years ago

The option c::set('autogit.widget', false) can be used to achieve that. You don't even need to hack Auto Git's code, add that logic inside site/config/config.php:

// ...

if (! panel()->user()->isAdmin()) {
    c::set('autogit.widget', false);
}

// ...

Since developer can create new roles and permissions, I preferred to leave it up to them to show or hide the widget as they needed.

Let me know if this option works for your needs 😉

tobystokes commented 8 years ago

Of course. That works. :thumbsup: