closed admin panel

This commit is contained in:
akosse
2020-01-29 11:26:01 +03:00
parent 75ccbff934
commit aa501900e4
29 changed files with 876 additions and 17 deletions

View File

@ -22,6 +22,12 @@ return [
],
],
'components' => [
'user' => [
'identityClass' => 'common\models\User',
'class' => 'yii\web\User',
'enableSession' => false,
'enableAutoLogin' => false,
],
'log' => [
'targets' => [
[

View File

@ -0,0 +1,36 @@
<?php
namespace console\controllers;
use Yii;
use yii\console\Controller;
class RbacController extends Controller
{
public function actionInit()
{
$auth = Yii::$app->authManager;
$secure = $auth->createPermission('secure');
$secure->description = 'Admin panel';
$auth->add($secure);
$front = $auth->createPermission('front');
$front->description = 'Frontend';
$auth->add($front);
$user = $auth->createRole('user');
$auth->add($user);
$auth->addChild($user, $front);
$admin = $auth->createRole('admin');
$auth->add($admin);
$auth->addChild($admin, $secure);
$auth->addChild($admin, $user);
$auth->assign($user, 2);
$auth->assign($admin, 1);
}
}