how to check whether my token is expired or not?
var token = jwt.sign(user,app.get('superSecret'),{
expiresIn : 2
});
I assume you are using the jsonwebtoken package that is documented here
If that is the case, have a look at the jwt.verify
method:
jwt.verify(token, 'shhhhh', function(err, decoded) {
if (err) {
/*
err = {
name: 'TokenExpiredError',
message: 'jwt expired',
expiredAt: 1408621000
}
*/
}
});
In short words: Check the error of that method. If it is the TokenExpiredError then, guess what... the token is expired.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With