jaredhanson / passport-facebook

Facebook authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-facebook/?utm_source=github&utm_medium=referral&utm_campaign=passport-facebook&utm_content=about
MIT License
1.3k stars 446 forks source link

Logout is not working #202

Open DIneshArun1991 opened 7 years ago

DIneshArun1991 commented 7 years ago

Below code is not logging out actually. still session is there. app.get('/logout',function(req,res){ req.logout(); res.redirect('/'); });

bartekwitczak commented 7 years ago

Hi,

req.logout() is not reliable, even though it's how documentation states. Please try that one in your handler:

req.session.destroy((err) => {
    if(err) return next(err)

    req.logout()

    res.sendStatus(200)
})
pszabop commented 7 years ago

Ran into same issue, the req.session.destroy workaround noted above fixes it. thanks!

obo20 commented 6 years ago

@bartekwitczak Thank you so much. Apparently that order is super important. I spent probably 4 hours trying to fix this issue until I found your solution.

FYI, I'm using create-react-app + node.js + express + passport.js

yo34 commented 5 years ago

using passport-github, I have similar problem :

when the logout route is called, the client application is no more connected. But if I click on login, the application does not redirect me to the github authentication page, and my client is still connected.

mauryakrishna commented 4 years ago

Seems I am facing the same issue. Invoking the logout as mentioned in the documentation. But when attempting to login again with facebook it directly takes me in.

How to remove the facebook stored login session so that fresh login can be made?

chriisduran commented 3 years ago

Same problem with Facebook logout!