Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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([