Skip to content

Commit 78c48fa

Browse files
committed
implement passReqToCallback
1 parent 7406f74 commit 78c48fa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/passport-http-oauth/strategies/consumer.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ function ConsumerStrategy(options, consumer, token, validate) {
125125
this._host = options.host || null;
126126
this._realm = options.realm || 'Clients';
127127
this._ignoreVersion = options.ignoreVersion || false;
128+
this._passReqToCallback = options.passReqToCallback || false;
128129
}
129130

130131
/**
@@ -320,11 +321,17 @@ ConsumerStrategy.prototype.authenticate = function(req) {
320321
if (self._validate) {
321322
// Give the application a chance it validate the timestamp and nonce, if
322323
// it so desires.
323-
self._validate(timestamp, nonce, function(err, valid) {
324+
var next = function(err, valid) {
324325
if (err) { return self.error(err); }
325326
if (!valid) { return self.fail(self._challenge('nonce_used')); }
326327
return ok();
327-
});
328+
};
329+
330+
if (self._passReqToCallback) {
331+
self._validate(req, timestamp, nonce, next);
332+
} else {
333+
self._validate(timestamp, nonce, next);
334+
}
328335
} else {
329336
return ok();
330337
}

0 commit comments

Comments
 (0)