title: Redirect user to previous page after auth (yii2)
body: <p>I have the main controller from which the others are inherited. Code is something like this</p>
  
  <pre><code>public function init()
  {
      $this-&gt;on('beforeAction', function ($event) {
          ...
  
          if (Yii::$app-&gt;getUser()-&gt;isGuest) {
              $request = Yii::$app-&gt;getRequest();
              // dont remember login page or ajax-request
              if (!($request-&gt;getIsAjax() || strpos($request-&gt;getUrl(), 'login') !== false))                  {
                 Yii::$app-&gt;getUser()-&gt;setReturnUrl($request-&gt;getUrl());
                }
             }
          }
          ...
      });
  }
  </code></pre>
  
  <p>It works perfectly for all pages, except the page with captcha. All the pages with captcha are redirected to something like this - /captcha/?v=xxxxxxxxxxxxxx</p>
  
  <p>If the object is logged Yii::$app->getRequest() then I see that for pages with captcha it is used twice. For the first time the object is corect, and the second time I see the object with captcha. 
  How can I solve this problem with yii? Is there a chance not to track the request for captcha?</p>