I'm a software engineer who creates full stack web applications. My favorite app is a Laravel + Nuxt SPA. I sometimes create a custom PHP app with a React frontend.
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?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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?