Here is my verification function:
exports.validateToken = function(req, res, next){
var token = req.body.token;
jwt.verify(token, config.sessionSecret, function(err, decoded) {
if(err){
return next(err);
}else{
var userToken = jwt.sign(req.body.user, config.secret,{
expiresIn:10000
});
res.json({token: userToken})
}
});
}
I'm expecting an error definition but I'm getting an internal server error on top of that:
TokenExpiredError: jwt expired
at Object.JWT.verify (/Users/Developer/node_modules/jsonwebtoken/index.js:209:19)
at exports.validateToken (/Users/Developer/app/controllers/user.signing.controller.js:369:9)
at Layer.handle [as handle_request] (/Users/Developer/node_modules/express/lib/router/layer.js:76:5)
at next (/Users/Developer/node_modules/express/lib/router/route.js:100:13)
at Route.dispatch (/Users/Developer/node_modules/express/lib/router/route.js:81:3)
at Layer.handle [as handle_request] (/Users/Developer/node_modules/express/lib/router/layer.js:76:5)
What am I doing wrong here?