Why is my Jwt token not being extracted?
OK I figured it out. I examined how my token generator function was working. I'm using mongoose and it was passing the id of the user model to the token like this:
function tokenForUser(user) { const timestamp = new Date().getTime(); //subject and issued at time return jwt.encode({ sub: user.id, iat: timestamp }, config.secret);}
I looked at the actual model that was being sent into this function and it turns out that mongoose adds an id with the key _id not id. Once I changed it to this everything works!
function tokenForUser(user) { const timestamp = new Date().getTime(); //subject and issued at time const userid = user['_id']; return jwt.encode({ sub: userid, iat: timestamp }, config.secret);}