Answer the question
In order to leave comments, you need to log in
Is it possible to restrict access to a page without using the RBAC bike?
There is an admin. Access to it is limited simply in the module:
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
];
}
Answer the question
In order to leave comments, you need to log in
public function behaviors()
{
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' => [
// allow authenticated users
[
'allow' => true,
'matchCallback' => function ($rule, $action) {
if (Yii::$app->user->id == 1){
return false;
} else {
return true;
}
}
],
// everything else is denied
],
],
];
}
you can, for example, by setting matchCallback , but is it worth it ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question