Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grant access to module in Yii2

Tags:

php

yii

This is possible to set permission with RBAC methods (Role, Permission) to access a module in Yii2?
I want to allow users with spacial Role to access for one of my module.

like image 502
Araz Jafaripur Avatar asked Dec 12 '22 02:12

Araz Jafaripur


1 Answers

I use Filter for this purpose:

'modules' => [
    'roles' => [
        'class' => 'aj\admin\Module',
        'as access' => [
            'class' => 'yii\filters\AccessControl',
            'rules' => [
                [
                    'allow' => true,
                    'roles' => ['Administrator'],
                ]
            ]
        ],
]
like image 186
Araz Jafaripur Avatar answered Dec 23 '22 01:12

Araz Jafaripur