fix admin access

parent 7b48b2d6
......@@ -30,5 +30,36 @@ abstract class AdminController extends \common\components\BaseController
{
throw new NotSupportedException('The requested page does not exist.');
}
$module = $this->getModuleName();
if($module && !Yii::$app->authManager->checkAccess(Yii::$app->user->id, $module))
{
throw new \Exception('There is no access to this page', 403);
}
}
private function getModuleName()
{
if(isset($this->module) && $this->module->id)
{
if($this->module->id == Yii::$app->id)
{
return null;
}
switch ($this->module->id)
{
case 'users':
return 'rbac';
break;
default:
return $this->module->id;
break;
}
}
return null;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment