Answer the question
In order to leave comments, you need to log in
In Yii2, what is the correct way to use $app->runAction()?
Hello!
I have such a problem
public function beforeAction($action){
$user_action = $action->controller->id.'/'.$action->id;
if (!in_array($user_action, Yii::$app->user->identity['rols']) ) {
return $this->redirect(['/admin/default/error']);
}
return parent::beforeAction($action);
}
public function beforeAction($action){
$user_action = $action->controller->id.'/'.$action->id;
if (!in_array($user_action, Yii::$app->user->identity['rols']) ) {
return Yii::$app->runAction('/admin/default/error');
}
return parent::beforeAction($action);
}
Answer the question
In order to leave comments, you need to log in
Judging by the code, you are trying to make a distinction between user rights, in this case you are reinventing the wheel. Access control filters and RBAC are used to differentiate access rights
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question