passport-facebook icon indicating copy to clipboard operation
passport-facebook copied to clipboard

Logout is not working

Open DIneshArun1991 opened this issue 7 years ago • 6 comments

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

DIneshArun1991 avatar Apr 20 '17 05:04 DIneshArun1991

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)
})

bartekwitczak avatar Apr 27 '17 14:04 bartekwitczak

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

pszabop avatar May 24 '17 16:05 pszabop

@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

obo20 avatar Aug 23 '18 16:08 obo20

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.

yo34 avatar May 30 '19 14:05 yo34

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?

mauryakrishna avatar Aug 19 '20 17:08 mauryakrishna

Same problem with Facebook logout!

chriisduran avatar Aug 10 '21 17:08 chriisduran