title: Redirect user to login page when session expires in Laravel
body: <p>I am trying to redirect a user back to the login page if their session has expired. I am using Laravel 5.5. I have edited my <code>RedirectIfAuthenticated</code> file to include the following code in the <code>handle</code> function:</p>
  
  <pre><code>if (!Auth::check()) {
      return redirect()-&gt;route('login', ['account' =&gt; 'demo']);
  }
  </code></pre>
  
  <p>When I do this, I am receiving the following error message:</p>
  
  <blockquote>
    <p>Missing required parameters for [Route: login] [URI: /].</p>
  </blockquote>
  
  <p>My <code>login</code> route is inside a subdomain route group which is why I am passing the <code>account</code> parameter. Here is part of my code in <code>web.php</code></p>
  
  <pre><code>// Subdomain routing
  Route::domain('{account}.ems.dev')-&gt;group(function () {
      Route::get('/', 'LoginController@show')-&gt;name('login');
  }
  </code></pre>
  
  <p>And here is my <code>LoginController@show</code> code:</p>
  
  <pre><code>/*
   * Show the login form
   */
  public function show($account) {
      // Validate this is a valid subdomain
      $organization = Organization::where('subdomain', $account)-&gt;first();
  
      if ($organization) { 
          return view('login');
      } else {
          return 'This account does not exist.';
      }
  }
  </code></pre>
  
  <p>Nothing I have tried works. I keep getting the exact same error message even though I am passing in the required parameters.</p>
  
  <h2>Update #1</h2>
  
  <p>Screenshot of error page:</p>
  
  <p><a href="https://i.stack.imgur.com/I5Z2U.png" rel="noreferrer"><img src="https://i.stack.imgur.com/I5Z2U.png" alt="enter image description here"></a></p>
  
  <h2>Update #2</h2>
  
  <p>After a little digging around the <em>Whoops!</em> error page, I see this, <code>protected function unauthenticated</code> is what is causing the problem:</p>
  
  <p><a href="https://i.stack.imgur.com/CfrsR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CfrsR.png" alt="enter image description here"></a></p>
  
  <p>How do I override this function to add the missing parameter?</p>