How to use the passport-jwt.Strategy.JwtVerifier function in passport-jwt

To help you get started, we’ve selected a few passport-jwt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coralproject / talk / services / passport.js View on Github external
if (
        cookieName in req.cookies &&
        req.cookies[cookieName] !== null &&
        req.cookies[cookieName].length > 0
      ) {
        return req.cookies[cookieName];
      }
    }
  }

  return null;
};

// Override the JwtVerifier method on the JwtStrategy so we can pack the
// original token into the payload.
JwtStrategy.JwtVerifier = (token, secretOrKey, options, callback) => {
  return jwt.verify(token, options, (err, jwt) => {
    if (err) {
      return callback(err);
    }

    // Attach the original token onto the payload.
    return callback(false, { token, jwt });
  });
};

// Extract the JWT from the 'Authorization' header with the 'Bearer' scheme.
passport.use(
  new JwtStrategy(
    {
      // Prepare the extractor from the header.
      jwtFromRequest: ExtractJwt.fromExtractors([