Get Laravel Sanctum Personal Access Token Plain Text, Generated previously
Hi everyone!
I have a login API, Whenever someone logs in, the API will generate a token and return to the user.
The problem is, if the user sends the request again and again even after receiving the token at the first. The API will generate another token everytime. So, I have found these solutions:
Delete old token whenever user logs in.
Check if a token already exists for the requested user login, then return the old token.
Problem in solution 1:
When user sends the login request he won't send the bearer token (obviously). So, how would I delete the old token of that user?
Why do you want to delete the previous token before generating a new one?
This behavior seems intentional and aligns with scenarios where users might want to stay logged in across multiple devices. Deleting the previous token each time a user logs in would effectively log them out from other devices, which might not be the desired outcome.