Araz Jafaripur Araz Jafaripur - 3 months ago 15
PHP Question

Grant access to module in Yii2

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.

Answer

I use Filter for this purpose:

'modules' => [
    'roles' => [
        'class' => 'aj\admin\Module',
        'as access' => [
            'class' => 'yii\filters\AccessControl',
            'rules' => [
                [
                    'allow' => true,
                    'roles' => ['Administrator'],
                ]
            ]
        ],
]
Comments