Skip to content
Browse files

Merge pull request #116 from playmoweb/fix-83

Fix getting AuthStrategy directly from package when Strategy key is n…
  • Loading branch information...
2 parents 047872b + c626b3f commit 6113bcbccc4698553e6d4710d3f0ca592873a4b9 @raymondfeng raymondfeng committed
Showing with 12 additions and 8 deletions.
  1. +12 −8 lib/passport-configurator.js
View
20 lib/passport-configurator.js
@@ -147,6 +147,10 @@ PassportConfigurator.prototype.configureProvider = function(name, options) {
options = options || {};
var link = options.link;
var AuthStrategy = require(options.module)[options.strategy || 'Strategy'];
+
+ if (!AuthStrategy) {
+ AuthStrategy = require(options.module);
+ }
var authScheme = options.authScheme;
if (!authScheme) {
@@ -171,18 +175,18 @@ PassportConfigurator.prototype.configureProvider = function(name, options) {
var callbackPath = options.callbackPath || ((link ? '/link/' : '/auth/') +
name + '/callback');
var callbackHTTPMethod = options.callbackHTTPMethod !== 'post' ? 'get' : 'post';
-
+
// remember returnTo position, set by ensureLoggedIn
var successRedirect = function(req){
- if (!!req && req.session && req.session.returnTo){
+ if (!!req && req.session && req.session.returnTo){
var returnTo = req.session.returnTo;
- delete req.session.returnTo;
+ delete req.session.returnTo;
return returnTo;
}
return options.successRedirect ||
- (link ? '/link/account' : '/auth/account');
- }
-
+ (link ? '/link/account' : '/auth/account');
+ }
+
var failureRedirect = options.failureRedirect ||
(link ? '/link.html' : '/login.html');
var scope = options.scope;
@@ -307,8 +311,8 @@ PassportConfigurator.prototype.configureProvider = function(name, options) {
// Fail to login if email is not verified or invalid username/password.
// Unify error message in order not to give indication about the error source for
// security purposes.
- if (ok && user.emailVerified)
- return done(null, userProfile);
+ if (ok && user.emailVerified)
+ return done(null, userProfile);
done(null, false, {message: errorMsg});
});

0 comments on commit 6113bcb

Please sign in to comment.
Something went wrong with that request. Please try again.