Answer the question
In order to leave comments, you need to log in
What about authorization?
I need your help again Comrades.
Found a glitch in the authorization system. If I go to the address: sitename.ru/admin, then it redirects to sitename.ru/site/login Everything is fine, I thought so. Until I went to the sitename.ru/admin/category address, instead of category , you can substitute any other controller that exists. I calmly navigate and the site opens the admin panel without authorization.
How can this be corrected?
Answer the question
In order to leave comments, you need to log in
Good evening.
Close each controller with yii\filters\AccessControl
Or configure rbac.
ps Read more here
For myself, I did so.
I created a function in the parent class that redirects from any page in the admin if the user is not authorized
public function beforeAction($action) {
if (Yii::$app->user->isGuest) {
return Yii::$app->getResponse()->redirect(Url::to(['/site/login/']));
}
return parent::beforeAction($action);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question