Skip to content

Commit

Permalink
Merge pull request #2 from jaysw/master
Browse files Browse the repository at this point in the history
Handle passReqToCallback option.
  • Loading branch information
pbuyle committed Apr 1, 2015
2 parents e73ba8e + d262d4f commit 985e09a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ function Strategy(secretOrPublicKey, options, verify) {

var strategy = this;

function jwtVerify(token, done) {
function jwtVerify(req, token, done) {
if (!options.passReqToCallback) {
token = arguments[0];
done = arguments[1];
req = null;
}
jwt.verify(token, secretOrPublicKey, options, function (err, token) {
if (err) {
if (err instanceof jwt.TokenExpiredError) {
Expand All @@ -89,11 +94,13 @@ function Strategy(secretOrPublicKey, options, verify) {
else {
done(err, false);
}
} else {
if (options.passReqToCallback) {
verify(req, token, done);
} else {
verify(token, done);
}
}

else

verify(token, done);
});
}
HTTPBearerStrategy.call(this, options, jwtVerify);
Expand Down

0 comments on commit 985e09a

Please sign in to comment.