Answer the question
In order to leave comments, you need to log in
Yii access - is it necessary to specify the list of actions in 'Only'?
I'm trying access control (filter). There is a Blog Controller and it has actions: index, add. With this code, for some reason, in any case (and with blog/index and blog/add), it throws on login, although only the add action is listed in the list:
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['add'],
'allow' => true,
'roles' => ['admin'],
],
],
]
];
}
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['add'],
'rules' => [
[
'actions' => ['add'],
'allow' => true,
'roles' => ['admin'],
],
],
]
];
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question