title: Laravel Auth: These credentials do not match our records
body: <p>I am really new to Laravel. And I am enjoying every bit of the framework. I have recently run into some problems with Authentication/Login.</p>
  
  <p>User registration works fine, but when I try to login using the same credentials created during registration, the app throws up this error:</p>
  
  <blockquote>
    <p>These credentials do not match our records</p>
  </blockquote>
  
  <p>I have also looked in the users table within the database and all the fields from the registration form is captured. I am just wondering why the app fails to retrieve these from the database.</p>
  
  <p>See below my LoginController code:</p>
  
  <pre><code>namespace App\Http\Controllers\Auth;
  
  use App\Models\User;
  use Illuminate\Http\Request;
  use App\Http\Controllers\Controller;
  use Illuminate\Foundation\Auth\AuthenticatesUsers;
  use Firebase\JWT\JWT;
  
  class LoginController extends Controller
  {
  /*
  |--------------------------------------------------------------------------
  | Login Controller
  |--------------------------------------------------------------------------
  |
  | This controller handles authenticating users for the application and
  | redirecting them to your home screen. The controller uses a trait
  | to conveniently provide its functionality to your applications.
  |
  */
  
  use AuthenticatesUsers;
  
  /**
   * Where to redirect users after login.
   *
   * @var string
   */
  protected $redirectTo = '/dashboard';
  
  // Get your service account's email address and private key from the JSON 
  key file
  protected $service_account_email = "abc-123@a-b-c-
  123.iam.gserviceaccount.com";
  
  protected $private_key = "-----BEGIN PRIVATE KEY-----...";
  
  /**
   * Create a new controller instance.
   *
   * @return void
   */
  public function __construct()
  {
      $this-&gt;middleware('guest')-&gt;except('logout');
  
      $this-&gt;service_account_email = config('services.firebase.client_email');
      $this-&gt;private_key = config('services.firebase.private_key');
  }
  
      /**
   * Get the needed authorization credentials from the request.
   *
   * @param  \Illuminate\Http\Request  $request
   * @return array
   */
  protected function credentials(Request $request)
  {
      $data = $request-&gt;only($this-&gt;username(), 'password');
      $data['email_confirmed'] = 1;
      return $data;
  }
  
  protected function authenticated(Request $request, $user)
  {
  
      $jwt = $this-&gt;create_custom_token($user,false);
  
      session(['jwt' =&gt; $jwt]);
  
      return redirect()-&gt;intended($this-&gt;redirectPath());
  }
  
  function create_custom_token(User $user, $is_premium_account) {
  
      $now_seconds = time();
      $payload = array(
          "iss" =&gt; $this-&gt;service_account_email,
          "sub" =&gt; $this-&gt;service_account_email,
          "aud" =&gt; "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
          "iat" =&gt; $now_seconds,
          "exp" =&gt; $now_seconds+(60*60),  // Maximum expiration time is one hour
          "uid" =&gt; $user-&gt;ref_code,
          "email" =&gt; $user-&gt;email,
          "name" =&gt; $user-&gt;name,
          "phone_number" =&gt; $user-&gt;phone_number,
          "claims" =&gt; array(
              "premium_account" =&gt; $is_premium_account
          )
      );
      return JWT::encode($payload, $this-&gt;private_key, "RS256");
      }
  
      }
  </code></pre>
  
  <p>How can I get this solved?</p>