Skip to content

Commit

Permalink
Merge pull request #34 from schmunk42/master
Browse files Browse the repository at this point in the history
added accessRoles param to configure access control
  • Loading branch information
Aris Karageorgos committed Dec 16, 2015
2 parents e6bd529 + bd424d8 commit 8c81f47
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ class Module extends \yii\base\Module
* @var string source language for translation
*/
public $sourceLanguage = 'en-US';


/**
* @var null|array The roles which have access to module controllers, eg. ['admin']. If set to `null`, there is no accessFilter applied
*/
public $accessRoles = null;

/**
* Init module
*/
Expand Down
10 changes: 10 additions & 0 deletions controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use pheme\settings\models\Setting;
use pheme\settings\models\SettingSearch;
use pheme\grid\actions\ToggleAction;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
Expand All @@ -36,6 +37,15 @@ public function behaviors()
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => $this->module->accessRoles,
],
],
],
];
}

Expand Down

0 comments on commit 8c81f47

Please sign in to comment.