title: Lumen: How to make Auth login for user using middleware?
body: <p>I'm trying to pass a username and password from a form into a controller, check if that user exists (users database table), and then redirect to an authenticated page where only users that are logged in can see their username.</p>
  
  <p>In my <code>routes.php</code>:</p>
  
  <pre><code>$app-&gt;post('/', ['uses' =&gt; 'AuthenticationController@login']);
  
  $app-&gt;group(['middleware' =&gt; 'auth'], function ($app) {
      $app-&gt;post('/tickets', ['uses' =&gt; 'TicketsController@getTickets']);
  });
  </code></pre>
  
  <p>Then my <code>AuthenticationController.php</code> login function:</p>
  
  <pre><code>public function login(Request $request) {
      $credentials = $request-&gt;only(['username','password']);
  
      $user = App\User::find($credentials);
  
      if ($user) {
          // I'm assuming you do a redirect() here but am unsure how with Auth
      } else {
          return 'not logged in';
      }
  }
  </code></pre>
  
  <p>At this point, I don't know what I need to put into my <code>getTickets</code> function in my TicketsController.php. </p>
  
  <p>Anyone that knows how to go about doing this, please throw me a bone as to how to proceed.</p>
  
  <p>Ultimately, it'll be great to have the <code>tickets.blade.php</code> view to have <code>{{ user-&gt;username }}</code> and to display the username of who's logged in. If the user doesn't log in and visits this view, nothing displays because they're not authenticated.</p>
  
  <p><strong>EDIT:</strong> Currently, I'm getting this error:</p>
  
  <blockquote>
    <p>FatalErrorException in AuthenticationController.php: Class
    'App\Http\Controllers\App\User' not found</p>
  </blockquote>
  
  <p>I do have both of these lines included in my <code>AuthenticationController.php</code> before all functions begin:</p>
  
  <pre><code>use App\User;
  use Auth;
  </code></pre>
  
  <p>Maybe it's the way I'm passing my <code>$credentials</code> into the find function, but that doesn't solve the Authentication side of things.</p>