Closed pixeltopic closed 5 years ago
Turns out this is a possible security issue, where if endpoints are called simultaneously it is possible that multiple jwts will be generated. Look into axios interceptors on the frontend
refreshToken
middleware from all routes as this should only be called by the axios interceptor from the client.error
to message
in responses.refreshToken
is now standalone and is only used by the /api/refreshtoken
endpoint.verifyToken
is no longer reliant on refreshToken
. Has also been rewritten.
Code is now a lot easier to read :)
refreshedToken
should be renamed totoken
, and should always return either the currently valid token or a refreshed token. The frontend will update the token on each call. The refreshed or current auth token should be sent in res.locals instead ofreq.auth
.