Skip to content

Commit

Permalink
Admin access via RBAC permission
Browse files Browse the repository at this point in the history
Commit to match feature added in pull request 600 of dektrium/yii2-user
  • Loading branch information
Talwoasc committed Jan 27, 2016
1 parent c6d315a commit d29ddc0
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 d29ddc0

Please sign in to comment.