forked from dektrium/yii2-rbac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule.php
50 lines (43 loc) · 1.17 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/*
* This file is part of the Dektrium project.
*
* (c) Dektrium project <http://github.com/dektrium>
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace dektrium\rbac;
use Yii;
use yii\base\Module as BaseModule;
use yii\filters\AccessControl;
/**
* @author Dmitry Erofeev <[email protected]>
*/
class Module extends BaseModule
{
/** @var bool Whether to show flash messages */
public $enableFlashMessages = true;
/** @var string */
public $defaultRoute = 'role/index';
/** @var array */
public $admins = [];
/** @inheritdoc */
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function () {
return in_array(Yii::$app->user->identity->username, $this->admins);
},
]
],
],
];
}
}