0

Node.js와 Express 4를 기반으로 웹 응용 프로그램을 만들고 있습니다. Passportjs와 Google OAuth 2 Startegy를 사용하여 인증하고 있습니다.요청 처리 기능으로 패스포트 인증 기능을 처리하는 방법

요청을 처리하기 위해 경로를 구성하려고합니다. 나는이 라인이 잘 작동하는지 배웠습니다 :

router.get('/signin/google/callback', passport.authenticate('google', {failureRedirect: '/signin'})); 

을하지만 함수의 경로를 처리하기로 결정했을 때, 응용 프로그램이 응답을 중지 :

router.get('/signin/google/callback', function (req, res) { 
    passport.authenticate('google', {failureRedirect: '/signin'}); 
}); 

내가 뭔가를 그리워합니까?

app.get('/auth/google/callback', 
    passport.authenticate('google', { failureRedirect: '/login' }), 
    function(req, res) { 
    res.redirect('/'); 
    }); 

passport.authenticate() 인수 request,response, next와 미들웨어 : 사전

답변

1

구글의 OAuth 함수의 콜백에 감사는 다음과 같이해야한다. 자신의 미들웨어 또는 마지막 요청 처리기를 정의 할 수도 있습니다.