From 380b5c87d028f8bf65ae35c75b2a306e65efd9bb Mon Sep 17 00:00:00 2001 From: Jared Hanson Date: Sun, 8 Dec 2019 16:03:53 -0800 Subject: [PATCH] Stylistic edits. --- lib/middleware/authenticate.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/middleware/authenticate.js b/lib/middleware/authenticate.js index 00db36ae..dc70cfc2 100644 --- a/lib/middleware/authenticate.js +++ b/lib/middleware/authenticate.js @@ -61,7 +61,7 @@ var http = require('http') * * passport.authenticate('twitter'); * - * @param {String|Array|Object} name + * @param {Strategy|String|Array} name * @param {Object} options * @param {Function} callback * @return {Function} @@ -182,15 +182,15 @@ module.exports = function authenticate(passport, name, options, callback) { // Get the strategy, which will be used as prototype from which to create // a new instance. Action functions will then be bound to the strategy // within the context of the HTTP request/response pair. - var prototype ; - if( typeof layer === 'object'){ - prototype = layer; - }else{ + var strategy, prototype; + if (typeof layer.authenticate == 'function') { + strategy = layer; + } else { prototype = passport._strategy(layer); + if (!prototype) { return next(new Error('Unknown authentication strategy "' + layer + '"')); } + + strategy = Object.create(prototype); } - if (!prototype) { return next(new Error('Unknown authentication strategy "' + layer + '"')); } - - var strategy = Object.create(prototype); // ----- BEGIN STRATEGY AUGMENTATION -----