Thursday 4 May 2017

Redirect to previous page using passport.js facebook strategy in express

This question have been posted before, but somehow the given recommendations don't work form me. Am stuck on this and not sure how to proceed.

I can't redirect the user back after its authentication. I'm using the recommended 'successReturnToOrRedirect' property, but it keeps sending it back to '/'. I have checked req.session.returnTo and req.path and both of them have '/' as value, even though I'm calling /auth/facebook from a different page.

Here's my code:

 router.get('/auth/facebook', passport.authenticate('facebook', {scope: ['email', 'public_profile', 'user_friends']}));

router.get('/auth/facebook/callback', 

      passport.authenticate('facebook', { successReturnToOrRedirect: '/',
                                          failureRedirect: '/' })

    );

    <a href="/auth/facebook"> <div class="fb-button-login">
            <i class="fa fa-facebook" aria-hidden="true"></i>
            Continuar con <strong> facebook</strong>
        </div> </a>



via Andrés Alagna

No comments:

Post a Comment