Twill CMSTC
Twill CMS4y ago
1 reply
trompix

permissions on Twill

Good morning. Tell me how to properly allow a user with a specific role to perform certain actions?

I have a user role and I want him to be able to post only articles. Thought to override the method. But instead of publishing, an edit action is available.

protected function getIndexOption($option)
{
if (Auth::guard('twill_users')->user()->can('reviewer-permission')) {

$authorizableOptions = [
'publish' => 'publish',
];
}

$authorized = array_key_exists($option, $authorizableOptions) ? Auth::guard('twill_users')->user()->can($authorizableOptions[$option]) : true;

return ($this->indexOptions[$option] ?? $this->defaultIndexOptions[$option] ?? false) && $authorized;
}
2022-11-01_13-05-41.png
Was this page helpful?