public function redirectUser($noauth, $authdefault) { // Get any of supplied redirect params. $redirectData = Oauth2::redirectData(); // Check if user is logged in. if (!Yii::$app->user->isGuest) { // Create redirect URL using current parameters if specified. $redirectURL = Oauth2::getSessionRedirectLocation($redirectData, true); // If the parameters created a valid redirect URL, go now. if ($redirectURL) { return $this->redirect($redirectURL); } // Failing that, send them to the auth default. return $this->redirect($authdefault); } // Not authenticated, send them to the non-authenticated page. // Store redirect information in session data if present. // Simplest way to reliably persist across any redirects. // Also persists across email activation links. if ($redirectData) { Oauth2::setSessionRedirect($redirectData); } return $this->redirect($noauth); }