一旦你安裝,直到你授予它mdmsoft/yii2管理員擴展訪問被拒絕所有路由。而不是硬編碼yii::$app->user-can('permission')
利用RBAC,這應該是您安裝mdmsoft/yii2-admin的唯一原因。
As Access Setup 希望您使用Yii2的高級模板。 最初,設置了爲您的frontend/config/main.php
訪問:
'as access' => [
//This access behavior must be in frontend and backend.
//The 'as access' behavior will interfere with migrations if put in common.
'class' => 'mdm\admin\components\AccessControl',
'allowActions' => [
'site/*', //Allow by default to all.
'debug/*',
//'admin/*', //Leave commented out, unless setting up admin roles initially.
//Allow guests to do:
'ticket/ticket/index',
]
],
設置RBAC
RBAC等級是這樣的:
用戶 - > Roles-> Permissions->路線
實施例
-Joey
--Admin_Role
---- Admin_Permission
--------應用程序/控制器1/*
--------應用程序/控制器2 /視圖
設置RBAC
- 首先添加您的路線。
- 添加您的權限。
- 爲您的權限分配路線。
- 創建您的角色。
- 爲您的角色分配權限。
- 爲用戶分配角色。
對於所需的功能,您應該使用您的類擴展模塊類,然後引用您的類。因此,當您更新擴展時,您的代碼未觸及,並且功能仍然有效 – scaisEdge