Answer the question
In order to leave comments, you need to log in
How to check if jwt is not lined?
Hello. Can you please tell me the best way to check if the jwt token that came from the server is not stitched? Thank you.
Answer the question
In order to leave comments, you need to log in
I think something like this:
...
const token = ctx.headers['x-token'];
if (token) {
try {
const { user } = jwt.verify(token, secretOne);
ctx.user = user;
} catch (err) {
const refreshToken = ctx.headers['x-refresh-token'];
const newTokens = await refreshTokens(
token,
refreshToken,
secretOne,
secretTwo
);
}
}
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question