Open CoderManSam opened 1 year ago
The JWT should have an iat
property which holds a unix timestamp, this is the "issued at" date/time:
{
"id": 5,
"username": "sam",
"iat": 1516239022
}
I'd decode the existing token to check if that exists first, if it doesn't then that's the property you should add to the payload to track when the token was created.
The "token has expired" message is great for the server-side response, I recommend the frontend devs display a more user friendly message like "Your session has expired. Please login again."
Approved!
-in generateJWT, add a variable to the paylaod with the date and time that the token is generated.
-in validateAuthentication add a check that checks that the date/time variable + the token expires_in has/hasn't surpassed the current date/time, if it has return an error 401 saying "token has expired"