DEV Community

Discussion on: User Authentication using Laravel's passport

Collapse
 
jacobhenning profile image
Jacob Henning

Awesome article! I found it super helpful.

I did have a question for you though. In your logout function, you go through the following steps:

1) Get token from the header
2) Parse token to get the id
3) Retrieve token from user tokens using said id
4) Take this retrieved token, and revoke it.

I wrote my logout function differently as follows

$request->user()->token()->revoke();

1) Grab the user from the request
2) Grab the current toke from user
3) Revoke the token taken from the user

I chose not to use the id at all. My question is should I be using the id? Is there ever a time where the token I'm logging out is not going to be the token assigned to the current user?