2016-06-27 14 views
0

どのようにパスポート局所戦略のチェックはとてもので、なぜ地元の戦略を作成するために同じことを確認することができ、私はまた私の地元の関数を呼び出すことができパスポート

// passport involved code 

app.post('/login', 
    passport.authenticate('local'), 
    function(req, res) { 
    // If this function gets called, authentication was successful. 
    // `req.user` contains the authenticated user. 
    res.redirect('/users/' + req.user.username); 
    }); 

カスタムコード対パスポート局所戦略

// custom checking function 

app.post('/login', 
    customfunctionhere, 
    function(req, res) { 
    // If this function gets called, authentication was successful. 
    // `req.user` contains the authenticated user. 
    res.redirect('/users/' + req.user.username); 
    }); 

答えて

0

はい、独自のローカル戦略機能を作成できます。しかし、パスポートはログイン(クッキー)を永続させ、簡単に成功と失敗を渡すなどの追加機能を提供します。

さらに、OAuthやgoogle/fb/twitterのシングルサインオンなどの他の戦略を使用している場合、すべての認証にパスポートを使用することは意味があります。

注:検証機能をpassport.authenticate()に渡すことはありません。詳細については、passport-localドキュメントをご確認ください:https://github.com/jaredhanson/passport-local

関連する問題