G
G
Greg Popov2016-06-18 01:28:36
Yii
Greg Popov, 2016-06-18 01:28:36

How to create rules in dektrium rbac for Yii2?

Hello. Installed dektrium/yii2-rbacand dektrium/yii2-user
backend
config:

'components' => [
        'user' => [
            'identityClass' => 'common\models\User',
            'identityCookie' => [
                'name'     => '_backendIdentity',
                'path'     => '/admin',
                'httpOnly' => true,
            ],
        ],
        'session' => [
            'name' => 'BACKENDSESSID',
            'cookieParams' => [
                'httpOnly' => true,
                'path'     => '/admin',
            ],
        ],
    'modules' => [
        'user' => [
            'as backend' => 'dektrium\user\filters\BackendFilter',
        ],
        'rbac' => [
            'class' => 'dektrium\rbac\Module',
        ],
    ],

frontend:
'user' => [
            'enableAutoLogin' => true,
            'identityClass' => 'common\models\User',
            'identityCookie' => [
                'name'     => '_frontendIdentity',
                'path'     => '/',
                'httpOnly' => true,
            ],
        ],
        'session' => [
            'name' => 'FRONTENDSESSID',
            'cookieParams' => [
                'httpOnly' => true,
                'path'     => '/',
            ],
        ],
    'modules' => [
        'user' => [
            // following line will restrict access to admin controller from frontend application
            'as frontend' => 'dektrium\user\filters\FrontendFilter',
        ],
        'rbac' => [
            'class' => 'dektrium\rbac\Module',
        ],
    ],

common
'user' => [
            'class' => 'dektrium\user\Module',
            'admins' => ['root'],
            'confirmWithin' => 21600,
            'cost' => 12,
            'enableConfirmation' => false, // @TODO remove this
        ],

I performed migrations, I create roles and permissions through the interface, I type in the Rules field, any time I try to enter an action, it says “Class "Foo" is missing”, what should I write there? Maybe the config is not valid?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question