I'm trying to setup JWT using Laravel.
I'm basically following the info form the jwt package and another page: https://github.com/tymondesigns/jwt-auth https://scotch.io/tutorials/token-based-authentication-for-angularjs-and-laravel-apps
I've got a few differences, mainly user model is called Human, but for the most part I'm following the examples above
The issue is that I can't validate a user. Whenever I hit the route with a post request I get the 401 Error. So I did some investigating in the php artisan tinker console. If I select the first user in my database check their password hash it's fine, this works:
$human = App\Human::first();
Hash::check('12345', $human['password']); // true
But if I try to generate a JWT, it fails.
JWTAuth::attempt(['email' => $human['email'], 'password' => '12345']); // false
I'm not sure where to go from here to debug this.
UPDATE: The key to this is that my 'user' table is actually called 'humans'. I had a user table hanging around in my database and as soon I removed it I got an error that the user table doesn't exist.
I did change this this line in my jwt config:
'user' => 'App\Human',
To reflect that my 'user' model is called Human, and I went into the laravel auth.php and set my model there also. Still when I call the JWTAuth attempt method it tries to access the 'users' table and not the 'humans' table where the passwords are actually stored.
Obviously I could change the table name but that makes another part of the application ugly. So I guess what I need is a way to configure jwt-auth to look at a different table.