Skip to content

Commit

Permalink
Merge pull request #54 from Talwoasc/master
Browse files Browse the repository at this point in the history
Admin access via RBAC permission
  • Loading branch information
dmeroff committed Mar 25, 2016
2 parents 566d3df + d29ddc0 commit a0b237b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class Module extends BaseModule

/** @var array */
public $admins = [];

/** @var string The Administrator permission name. */
public $adminPermission;

/** @inheritdoc */
public function behaviors()
Expand All @@ -44,7 +47,7 @@ public function behaviors()
if (method_exists($user, 'getIsAdmin')) {
return $user->getIsAdmin();
} else {
return in_array($user->username, $this->admins);
return (\Yii::$app->getAuthManager() && $this->adminPermission ? \Yii::$app->user->can($this->adminPermission) : false) || in_array($this->username, $this->admins);
}
},
]
Expand Down

0 comments on commit a0b237b

Please sign in to comment.