title: Laravel 5.2 Auth middleware redirect back issue
body: <p>Goal: When a user tries to access a route only meant for 'logged in users'. I want to redirect the user back from where he came with a basic login modal shown.</p>
  
  <p>My Auth middleware:</p>
  
  <pre><code>public function handle($request, Closure $next, $guard = null)
  {
      if (Auth::guard($guard)-&gt;guest()) {
          if ($request-&gt;ajax() || $request-&gt;wantsJson()) {
              return response('Unauthorized.', 401);
          } else {
              return redirect()-&gt;back()-&gt;with('error_code', 5);
          }
      }
  }
  </code></pre>
  
  <p>On redirect i successfuly managed to open the basic login modal.</p>
  
  <p>Problem: After entering the credentials and hitting login. The user is redirected to homepage and not to the intended route/page. </p>
  
  <p>The logic works fine when i use </p>
  
  <pre><code>public function handle($request, Closure $next, $guard = null)
  {
      if (Auth::guard($guard)-&gt;guest()) {
         if ($request-&gt;ajax() || $request-&gt;wantsJson()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()-&gt;guest('/')-&gt;with('error_code', 5);
         }
     }
  }
  </code></pre>
  
  <p>But this always redirects to homepage with the modal open. Which is not what i desire. </p>
  
  <p>How can i fix this?</p>
  
  <p>TIA</p>