Reputation: 24472
I'm using laravel as my backend. Once the user has logged into my app, all I have is just a token without any information regards the username or any other user details.
Once I retrive the JWT Token and store it in my frontend (angular2), how I can get the user details?
For the record, i'm using the following laravel library: https://github.com/tymondesigns/jwt-auth
Upvotes: 2
Views: 5830
Reputation: 2703
I have tested just
$user = JWTAuth::toUser();
Without any parameter and it works as well I am using Laravel 7.3 with tymon/jwt-auth 1.0
Upvotes: 0
Reputation: 861
To get the user information
First get the token from JWTAuth like this:
$token = JWTAuth::getToken();
Then get the user from the token as follows:
$user = JWTAuth::toUser($token);
Upvotes: 4
Reputation: 183
you can get user information like this way :
$user = JWTAuth::toUser(your_token_here);
Upvotes: 0