mikenicholson/passport-jwt

Update cookieExtractor function in docs.

Borduhh opened this issue · 1 comments

The cookieExtractor function in the docs should be updated to match the other functions in the /lib/extract_jwt.js file.

In docs:

var cookieExtractor = function(req) {
    var token = null;
    if (req && req.cookies)
    {
        token = req.cookies['jwt'];
    }
    return token;
};

Corrected to:

var cookieExtractor = function(cookie_name) {
    return function(req) {
        var token = null;
        if (req && req.cookies)
        {
           token = req.cookies[cookieName];
        }
        return token;
    }
};

The point of the function in the docs is to provide a very easy to understand example of a custom extractor function, not another more generic (but also more complicated) implementation of the provided extractors.

Functions returning functions might be a little confusionfor less experienced devs and aren't necessary for a working extractor function.