Put a restriction on access to the action controller, prescribed the following rule:
[ 'allow' => true, 'actions' => ['login' , 'registration'], 'roles' => ['?'], ], Everything works correctly, but how can you make it so that when a rule is not executed (that is, a logged in user goes through the hook), a non-standard warning of the type is thrown :
Error: yii \ web \ ForbiddenHttpException:
and showed a definite page?