Answer the question
In order to leave comments, you need to log in
How to restrict guest access to the admin panel?
Good evening. Can you please tell me how in Yii it is possible to restrict a guest's access to the admin panel and, when entering any page of the admin panel, give him a login view? What is the best way to do this? Inherit one controller to another? Use the init() method? Tried to make a simple redirect:
if (Yii::$app->user->isGuest) {
return $this->redirect('/admin/login');
}
Answer the question
In order to leave comments, you need to log in
Use AccessControl filter in base controller www.yiiframework.com/doc-2.0/guide-security-author...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question