2016-09-28 9 views
0

は、私はこのような戦略オブジェクトを作成しています:私のデバッガでパスポートLocalStrategy一貫性のないクラス名

var strat = new LocalStrategy({ 
      usernameField: 'email' 
     }, 
     function(username, password, done) { 
      User.findOne({ email: username }, function (err, user) { 
       if (err) { return done(err); } 
       // Return if user not found in database 
       if (!user) { 
        return done(null, false, { 
         message: 'User not found' 
        }); 
       } 
       // Return if password is wrong 
       if (!user.validPassword(password)) { 
        return done(null, false, { 
         message: 'Password is wrong' 
        }); 
       } 
       // If credentials are correct, return the user object 
       return done(null, user); 
      }); 
     } 
    ); 

が、私はストラトオブジェクトはクラス「戦略」のインスタンスであることがわかります。それはLocalStrategyのconscructorを経て作成されてから

enter image description here

は、それが "LocalStrategy" のインスタンスではないでしょうか?

答えて

1

次は通常、あなたは戦略がエクスポートされたシンボルとthe name of the strategy constructorの名前で見ることができるように局所戦略

var LocalStrategy = require('passport-local').Strategy; 

を使用してセットアップpassportjsにやるされているもののコードの例の一部です。 LocalStrategyは、使用しているローカル変数の名前です。

関連する問題