Redirect Causing Redirect Loop

So I’m trying to use a redirect() within beforeAction() and all that is resulting is a redirect loop.

I understand the problem. An action occurs, beforeAction() takes over, invokes redirect(), which invokes an action, which invokes beforeAction(), and so on and so forth…

I have not been able to figure out a way around this yet. Some help would be appreciated.

Got it figured out with some help on github, needed a double conditional. For those who are doing something similar, here is the code.


    public function beforeAction($action)

    {

        if (Yii::$app->user->userStatus && $this->getRoute() != 'site/about') {

            $this->redirect(['site/about']);

        }

        return true;

    }