为什么dektrium不起作用?

时间:2016-11-18 13:21:33

标签: php yii yii2 rbac

我安装了新的yii2。安装了dektrium / yii2-rbac。通过迁移更新了我的数据库架构我没有配置authManager组件。我的配置文件:

'components' => [
    'request' => [
        'cookieValidationKey' => 'asdasd123456qwerty',
    ],
    ...
    'user' => [
        'identityClass' => 'app\models\User',
        'enableAutoLogin' => true,
    ],
    ...
    'db' => require(__DIR__ . '/db-local.php'),
    'urlManager' => [...],
],
'params' => $params,
'modules' => [
    'rbac' => 'dektrium\rbac\RbacWebModule',
],

当我尝试获取localhost / basic / web / rbac(默认管理员/管理员)时,我得到403 Forbidden。错误在哪里?

2 个答案:

答案 0 :(得分:1)

'modules' => [
    'rbac' => [
        'class' => 'dektrium\rbac\RbacWebModule',
        'admins' => ['admin'],
    ]
],

这是一个答案!

答案 1 :(得分:0)

我认为您需要在配置文件中配置authManager

'components' => [
    ...
    'authManager' => [
        'class' => 'dektrium\rbac\components\DbManager',
    ],
    ...
],
...