mirror of
https://github.com/CyanoFresh/SmartHomePHP.git
synced 2026-03-04 00:54:03 +01:00
Close #36 - admin panel only for admins
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace app\modules\admin;
|
||||
|
||||
use Yii;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
/**
|
||||
* admin module definition class
|
||||
@@ -13,6 +15,26 @@ class Module extends \yii\base\Module
|
||||
* @inheritdoc
|
||||
*/
|
||||
public $controllerNamespace = 'app\modules\admin\controllers';
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return ArrayHelper::merge(parent::behaviors(), [
|
||||
'access' => [
|
||||
'class' => AccessControl::className(),
|
||||
'rules' => [
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
'matchCallback' => function () {
|
||||
return Yii::$app->user->identity->isAdmin;
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
|
||||
Reference in New Issue
Block a user