Application template: advanced I have 2 applications: backend and frontend.
It is necessary for me that in backend all roles, except client have access.
I wrote the following in main.php:
'as beforeRequest' => [ 'class' => 'yii\filters\AccessControl', 'rules' => [ [ 'allow' => true, 'controllers' => ['site'], 'actions' => ['login'], ], [ 'allow' => false, 'roles' => ['client'], ], ], 'denyCallback' => function () { return Yii::$app->response->redirect(['site/login']); }, ], As a result, I get the error: ERR_TOO_MANY_REDIRECTS
As I understand it all happens like this:
- User logs on to site / login.
- Authorized in the system. He has a
clientrole. Access is denied. - There is a redirect to site / login.
- User is already authorized. And he has a
clientrole. Access is denied. - See 3
Endless redirect ...
How to avoid it and close access?
site/loginif access isdenyCallback-denyCallback. Remove processing, see what happens. Or, log out the user and return to the login page. Or show him the page that he is forbidden to visit. - Bookin