title: Laravel - Unauthenticated redirect issue with multiple authentication
body: <p>I have a multiple authentication system set up in Laravel 5.7</p>
  
  <p>There is an 'admin' section of the site and a 'learner' section of the site.
  When you try to access a portion of either site, it redirects you the correct login page if you're not logged in yet.</p>
  
  <p>However, if follow these steps, I come across an issue with the redirects:</p>
  
  <ol>
  <li>I try to access a portion (not the login) of the 'admin' site, which redirects me to the admin login. </li>
  <li>Then if I link DIRECTLY to the login section of the 'learner' page
  and log in, instead of going to the home page it will redirect me
  back to the admin login.</li>
  </ol>
  
  <p>It properly logs me in, but improperly redirects to the other login page.
  The issue also happens vice versa, if I get an automatic redirect to the 'learner' then link directly to the admin login page and log in.</p>
  
  <p>I believe I've narrowed the issue down to the unaunthenticated function I've placed in the Exception/Handler.php file, but I can't figure out where to go from there.</p>
  
  <pre><code>protected function unauthenticated($request, AuthenticationException $exception)
      {
          if ($request-&gt;expectsJson()) {
              return response()-&gt;json(['error' =&gt; 'Unauthenticated.'], 401);
          }
          $guard = array_get($exception-&gt;guards(), 0);
          switch ($guard) {
              case 'learner':
                  $login = 'learner.login';
                  break;
              default:
                  $login = 'login';
                  break;
          }
          return redirect()-&gt;guest(route($login));
      }
  </code></pre>
  
  <p>Using each separate login page works fine. It's just when you follow the process above that I  see issues. </p>
  
  <p>I use separate middleware in each controller like this:</p>
  
  <p>Admin Home Controller</p>
  
  <pre><code>public function __construct()
      {
          $this-&gt;middleware('auth');
      }
  </code></pre>
  
  <p>Admin login controller:</p>
  
  <pre><code>public function __construct()
      {
          $this-&gt;middleware('guest')-&gt;except('logout');
      }
  </code></pre>
  
  <p>Learner home controller</p>
  
  <pre><code>public function __construct()
      {
          $this-&gt;middleware('auth:learner');
  
      }
  </code></pre>
  
  <p>Learner login Controller:</p>
  
  <pre><code>public function __construct()
      {
          $this-&gt;middleware('guest:learner')-&gt;except('logout');
      }
  </code></pre>
  
  <p>Solution: Clearing out the intended url with Session:forget('url.intended');</p>
  
  <pre><code>protected function unauthenticated($request, AuthenticationException $exception)
      {
          // dd($exception);
          if ($request-&gt;expectsJson()) {
              return response()-&gt;json(['error' =&gt; 'Unauthenticated.'], 401);
          }
          $guard = array_get($exception-&gt;guards(), 0);
          switch ($guard) {
              case 'learner':
                  $login = 'learner.login';
                  break;
              default:
                  $login = 'login';
                  break;
          }
          Session::forget('url.intented'); 
          return redirect()-&gt;route($login);
      }
  </code></pre>