mikenicholson/passport-jwt

JWT Passport authentication middleware never called!

CYB3RL1F3 opened this issue · 1 comments

Hello,

Here is my code, maybe I do it wrong?

Since I upgraded to jwt 4, it doesn't work anymore. I manage to login but when I try to access to the secured route, I directly go into the "secured" function, and the middleware is never called...

A clue?

app.use(passport.initialize());
const jwtstrategy = new JWTStrategy(
      {
         jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
         secretOrKey: __JWT__,
         passReqToCallback: true
      },
      async (req: Request, payload: AuthenticationPayload, done) => {
        console.log('>>>> SHOULD PASS HERE BUT DOESN'T !!!!!!!!');
      }
)
passport.use('jwt', jwtstrategy)

  app.get('/secured', passport.authenticate('jwt', {
      session: false,
      failureRedirect: "/forbidden"
    }), (req, res...)

Finally it was an error in my code, everything works well, sorry for the issue.