@@ -205,9 +205,10 @@ PassportConfigurator.prototype.configureProvider = function(name, options) {
205205 } ;
206206 } ;
207207
208+ var strategy ;
208209 switch ( authType ) {
209210 case 'ldap' :
210- passport . use ( name , new AuthStrategy ( _ . defaults ( {
211+ strategy = new AuthStrategy ( _ . defaults ( {
211212 usernameField : options . usernameField || 'username' ,
212213 passwordField : options . passwordField || 'password' ,
213214 session : options . session , authInfo : true ,
@@ -235,10 +236,10 @@ PassportConfigurator.prototype.configureProvider = function(name, options) {
235236 done ( null ) ;
236237 }
237238 }
238- ) ) ;
239+ ) ;
239240 break ;
240241 case 'local' :
241- passport . use ( name , new AuthStrategy ( _ . defaults ( {
242+ strategy = new AuthStrategy ( _ . defaults ( {
242243 usernameField : options . usernameField || 'username' ,
243244 passwordField : options . passwordField || 'password' ,
244245 session : options . session , authInfo : true ,
@@ -319,12 +320,12 @@ PassportConfigurator.prototype.configureProvider = function(name, options) {
319320 }
320321 } ) ;
321322 }
322- ) ) ;
323+ ) ;
323324 break ;
324325 case 'oauth' :
325326 case 'oauth1' :
326327 case 'oauth 1.0' :
327- passport . use ( name , new AuthStrategy ( _ . defaults ( {
328+ strategy = new AuthStrategy ( _ . defaults ( {
328329 consumerKey : options . consumerKey ,
329330 consumerSecret : options . consumerSecret ,
330331 callbackURL : callbackURL ,
@@ -347,10 +348,10 @@ PassportConfigurator.prototype.configureProvider = function(name, options) {
347348 } , options , loginCallback ( req , done ) ) ;
348349 }
349350 }
350- ) ) ;
351+ ) ;
351352 break ;
352353 case 'openid' :
353- passport . use ( name , new AuthStrategy ( _ . defaults ( {
354+ strategy = new AuthStrategy ( _ . defaults ( {
354355 returnURL : options . returnURL ,
355356 realm : options . realm ,
356357 callbackURL : callbackURL ,
@@ -370,10 +371,10 @@ PassportConfigurator.prototype.configureProvider = function(name, options) {
370371 { identifier : identifier } , options , loginCallback ( req , done ) ) ;
371372 }
372373 }
373- ) ) ;
374+ ) ;
374375 break ;
375376 case 'openid connect' :
376- passport . use ( name , new AuthStrategy ( _ . defaults ( {
377+ strategy = new AuthStrategy ( _ . defaults ( {
377378 clientID : clientID ,
378379 clientSecret : clientSecret ,
379380 callbackURL : callbackURL ,
@@ -397,10 +398,10 @@ PassportConfigurator.prototype.configureProvider = function(name, options) {
397398 options , loginCallback ( req , done ) ) ;
398399 }
399400 }
400- ) ) ;
401+ ) ;
401402 break ;
402403 default :
403- passport . use ( name , new AuthStrategy ( _ . defaults ( {
404+ strategy = new AuthStrategy ( _ . defaults ( {
404405 clientID : clientID ,
405406 clientSecret : clientSecret ,
406407 callbackURL : callbackURL ,
@@ -424,9 +425,11 @@ PassportConfigurator.prototype.configureProvider = function(name, options) {
424425 options , loginCallback ( req , done ) ) ;
425426 }
426427 }
427- ) ) ;
428+ ) ;
428429 }
429430
431+ passport . use ( name , strategy ) ;
432+
430433 var defaultCallback = function ( req , res , next ) {
431434 // The default callback
432435 passport . authenticate ( name , _ . defaults ( { session : session } ,
@@ -575,4 +578,6 @@ PassportConfigurator.prototype.configureProvider = function(name, options) {
575578 var queryString = url + separator + fieldValuePair ;
576579 return queryString ;
577580 }
581+
582+ return strategy ;
578583} ;
0 commit comments