jwt-auth: Returns ["user_not_found"] on authentication with user
After generating a token on user registration and using it to authenticate user,returns this: ["user_not_found"]
i am using laravel 5.1
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16 (2 by maintainers)
This actually worked for me.
$authuser = JWTAuth::toUser(JWTAuth::getToken());. I still passed the token through Authorization header. But this$user = JWTAuth::parseToken()->authenticate();as found in the documentation did not work.Thanks. I got the same error. but, fixed it by overriding the $primaryKey variable with my custom db field in my user class like, File: app\Models\User.php class User extends Model implements AuthenticatableContract, CanResetPasswordContract { … /** * The primary key for the model. * * @var string */ protected $primaryKey = ‘userID’;
Yea right. If the primary key is different then set primary key name in the user model. protected $primaryKey = “UserId”;
So that the below function will return the value of the primarykey,
So the jwt token claim “sub” will contain the user id value. Which is used to fetch the user information from the token.
Also you can set more custom claims in the model using , public function getJWTCustomClaims() { return [‘email’ => $this->getAttributeValue(‘Email’) ]; }
This issues caused me lot of time waste. Hope this will help some one else.
I am using Lumen 5.8 and Tymon jwt 1.0.*
IDK if this will help anyone else out but I was having a similar issue and stumbled on this thread. I had to set the identifier because we use unorthodox naming conventions.
It was looking for an id field so it would not set the sub header