여권

2016-06-27 3 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