title: How can i use cartalyst sentinel with tymon jwt in Laravel 5.6?
body: <p>I'm wondering how to implement tymon jwt 1.0.0 rc2 with Cartalyst Sentinel 2.0 authentication package in Laravel 5.6 to take advantage of throttling and others Sentinel features.</p>
  
  <p>Inside AuthController I have this login() method as mentioned in jwt-auth Docs <a href="https://jwt-auth.readthedocs.io/en/develop/quick-start/" rel="nofollow noreferrer">enter link description here</a> to validate the credentials and generate a token.</p>
  
  <pre><code>public function login()
  {
      $credentials = request(['email', 'password']);
  
      if (! $token = auth()-&gt;attempt($credentials))
          return response()-&gt;json(['error' =&gt; 'Unauthorized'], 401);
  
      return $this-&gt;respondWithToken($token);
  }
  </code></pre>
  
  <p>What I did is the following</p>
  
  <pre><code>public function login()
  {
      $credentials = request(['email', 'password']);
  
      if (! Sentinel::authenticate($credentials))
          return response()-&gt;json(['error' =&gt; 'Unauthorized'], 401);
  
      $token = auth()-&gt;attempt($credentials);
      return $this-&gt;respondWithToken($token);
  }
  </code></pre>
  
  <p>But i don't think this is the right way because there is a double authentication, first by Sentinel and the second by jwt. and this is bad for performance.</p>
  
  <p>And second workaround is to modify attempt() method inside JWTGuard class that resides in vendor/tymon/jwt-auth/src folder.</p>
  
  <p>the default is the following</p>
  
  <pre><code>public function attempt(array $credentials = [], $login = true)
  {
      $this-&gt;lastAttempted = $user = $this-&gt;provider-&gt;retrieveByCredentials($credentials);
  
      if ($this-&gt;hasValidCredentials($user, $credentials)) {
          return $login ? $this-&gt;login($user) : true;
      }
  
      return false;
  
  }
  </code></pre>
  
  <p>and I changed it like this</p>
  
  <pre><code>public function attempt(array $credentials = [], $login = true)
  {
      if ($user = Sentinel::authenticate($credentials)) {
          return $this-&gt;login($user);
      }
  
      return false;
  }
  </code></pre>
  
  <p>I don't now if this is a right solution or not ?</p>