dev-master
9999999-devRole Base Access for EasyiiCMS
MIT
The Requires
module cms yii easyiicms
Role Base Access for EasyiiCMS
This module allows add Rbac module to Easy yii2 cms, (*1)
Please, install User module for EasyiiCMS by following these instructions before going further, (*2)
$ php composer.phar require developeruz/easyii-rbac-module "dev-master"
Replace last line in app/config/web.php
, (*3)
$config = array_merge_recursive($config, require($webroot . '/vendor/developeruz/easyii-user-module/config/user_module_config.php'), require($webroot . '/vendor/noumo/easyii/config/easyii.php')); $config['components']['user'] = [ 'identityClass' => 'developeruz\easyii_user\models\User' ]; return $config;
with, (*4)
$config = array_merge_recursive($config, require($webroot . '/vendor/developeruz/easyii-user-module/config/user_module_config.php'), require($webroot . '/vendor/developeruz/easyii-rbac-module/config/rbac_module_config.php'), require($webroot . '/vendor/noumo/easyii/config/easyii.php')); $config['components']['user'] = [ 'identityClass' => 'developeruz\easyii_rbac\models\User' ]; return $config;
Add authManager to components in app/config/console.php
and app/config/web.php
, (*5)
'components' => [ ... 'authManager' => [ 'class' => 'yii\rbac\DbManager', ], ]
Run authManager migrations, (*6)
php yii migrate --migrationPath=@yii/rbac/migrations/
Run migrations, (*7)
php yii migrate --migrationPath=@vendor/developeruz/easyii-rbac-module/migrations
Open User CRUD page (url admin/user
), you will see change user role
button in action buttons column. Click on it and assign Admin
role to admin user., (*8)
Add behaviour in app/config/web.php
, (*9)
'components' => [ ... ], 'modules' => [ ... ], 'as AccessBehavior' => [ 'class' => \developeruz\db_rbac\behaviors\AccessBehavior::className(), 'login_url' => '/admin/sign/in', 'rules' => [ 'user/security' => [['actions' => ['login'], 'allow' => true ], ['actions' => ['logout'], 'roles' => ['@'], 'allow' => true ]], 'user/settings' => [['roles' => ['@'], 'allow' => true ]], 'admin/sign' => [['actions' => ['in'], 'allow' => true], ['actions' => ['out'], 'roles' => ['@'], 'allow' => true ]], 'site' =>[[ 'allow' => true]], 'articles' =>[[ 'allow' => true]], 'gallery' =>[[ 'allow' => true]], 'news' =>[[ 'allow' => true]], ], ]
Add all public controllers in rules
., (*10)
If the user doesn't have access to admin panel, admin Toolbar will be hidden on front pages via adding css display:none
.
It is compelled workaround because Easy yii2 cms doesn't allow to overwrite this part.
I will create PR and change the behavior in this module as soon as it would be possible., (*11)
The MIT License (MIT). Please see License File for more information., (*12)
Role Base Access for EasyiiCMS
MIT
module cms yii easyiicms