Skip to content

Commit

Permalink
No need to bind returned middleware functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Jan 25, 2014
1 parent 9f6af1f commit c84c312
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/authenticator.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Authenticator.prototype.initialize = function(options) {
options = options || {};
this._userProperty = options.userProperty || 'user';

return this._framework.initialize().bind(this);
return this._framework.initialize(this);
}

/**
Expand Down Expand Up @@ -164,7 +164,7 @@ Authenticator.prototype.initialize = function(options) {
* @api public
*/
Authenticator.prototype.authenticate = function(strategy, options, callback) {
return this._framework.authenticate(strategy, options, callback).bind(this);
return this._framework.authenticate(this, strategy, options, callback);
}

/**
Expand Down Expand Up @@ -192,7 +192,7 @@ Authenticator.prototype.authorize = function(strategy, options, callback) {
options.assignProperty = 'account';

var fn = this._framework.authorize || this._framework.authenticate;
return fn(strategy, options, callback).bind(this);
return fn(this, strategy, options, callback);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions lib/middleware/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var http = require('http')
* @return {Function}
* @api public
*/
module.exports = function authenticate(name, options, callback) {
module.exports = function authenticate(passport, name, options, callback) {
if (typeof options == 'function') {
callback = options;
options = {};
Expand All @@ -78,8 +78,6 @@ module.exports = function authenticate(name, options, callback) {
}

return function authenticate(req, res, next) {
var passport = this;

// accumulator for failures from each strategy in the chain
var failures = [];

Expand Down
3 changes: 1 addition & 2 deletions lib/middleware/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@
* @return {Function}
* @api public
*/
module.exports = function initialize() {
module.exports = function initialize(passport) {

return function initialize(req, res, next) {
var passport = this;
req._passport = {};
req._passport.instance = passport;

Expand Down

0 comments on commit c84c312

Please sign in to comment.