Closed DzmitryU closed 7 years ago
Hello everyone!
Now I use following code for authentication:
const jwtOptions = { jwtFromRequest: ExtractJwt.fromAuthHeader(), secretOrKey: 'jwtSecret' }; ... passport.use(new JwtStrategy(jwtOptions, (payload, done) => done(null, payload))); ... passport.authenticate('jwt', { session: false }, (err, payload) => { if (payload) { ... } else { ... } })
But for expired and wrong token I get payload=false and err=null. Does there exist any way to handle this different cases and determine what caused empty payload? (if token was wrong/missing or expired)
Add a third parameter to the authenticate callback (e.g. info). If verification fails that will contain the specific error.
authenticate
info
See #75 for more info
Looks like @noinkling answered the question sufficiently.
Hello everyone!
Now I use following code for authentication:
But for expired and wrong token I get payload=false and err=null. Does there exist any way to handle this different cases and determine what caused empty payload? (if token was wrong/missing or expired)