title: Laravel passport check if user is active before login
body: <p>I using <strong>Guzzle</strong> to send post request to passport <code>oauth/token</code> and here is the code:</p>
  
  <pre><code>public function login (Request $request) {
      $http = new \GuzzleHttp\Client;
  
      try {
          $response = $http-&gt;post(config('services.passport.login_endpoint'), [
              'form_params' =&gt; [
                  'grant_type' =&gt; 'password',
                  'client_id' =&gt; config('services.passport.client_id'),
                  'client_secret' =&gt; config('services.passport.client_secret'),
                  'username' =&gt; $request -&gt; email,
                  'password' =&gt; $request -&gt; password,
              ],
          ]);
          return $response-&gt;getBody();
      } catch (\GuzzleHttp\Exception\BadResponseException $e) {
          if ($e-&gt;getCode() === 400)
              return response()-&gt;json('Invalid Request. Please enter a username or a password.', $e-&gt;getCode());
          else if ($e-&gt;getCode() === 401)
              return response()-&gt;json('Your credentials are incorrect. Please try again', $e-&gt;getCode());
          else if ($e-&gt;getCode() === 408)
              return response()-&gt;json('User is deactivated. Please try again', $e-&gt;getCode());
  
          return response()-&gt;json('Something went wrong on the server.', $e-&gt;getCode());
      }
  }
  </code></pre>
  
  <blockquote>
    <p>What I am trying to do:</p>
  </blockquote>
  
  <p>I have an active field for each user <code>1 is active and 0 is deactivated</code>.</p>
  
  <p>I want to check before the user login if active or not and send a response with 408 code and message like i did in the if statement.</p>
  
  <blockquote>
    <p>What I have tried to do:</p>
  </blockquote>
  
  <p>I have tried to add this to <code>User.php</code> model:</p>
  
  <pre><code>public function findForPassport($identifier) {
      return User::orWhere('email', $identifier)-&gt;where('active', 1)-&gt;first();
   }
  </code></pre>
  
  <p>It works fine.</p>
  
  <blockquote>
    <p>Problem is:</p>
  </blockquote>
  
  <p>1) This return a response with 401 if not active and I want to return 408.</p>
  
  <p>2) I don't know if this is the best way to do it or not.</p>