Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logout controller has a bug when destroying the session #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

drebel
Copy link
Owner

@drebel drebel commented Dec 16, 2023

set up the post request to log out but running into problems with the implentation of the postLogout controller in authcontroller

postLogout: (req, res) => {
// console.log(req)
// res.send('hey back')
console.log('inside logout')
console.log('before logout - req.session:', req.session)
try{
req.logout(() => {
console.log('User has logged out')
console.log('after logout - req.session:', req.session)

    req.session.destroy((err) => {
      if(err){
        console.log('Error: Failed to destory the session during logout', err)
      }
      req.user = null

      res.status(200).send('User logged out')

    })
  })

}catch(err){
  console.error('error during logout:', err)
  res.status(500).send('Internal Server Error')
}

}
}

right now i had to downgrade the passport package to 0.5.3 instead of most recent 0.7.0

when i tried to destroy the session on log out it would throw an error described by others here
https://stackoverflow.com/questions/50454992/req-session-destroy-and-passport-logout-arent-destroying-cookie-on-client-side
and here
jaredhanson/passport#907

i might be misunderstanding how logout works but i think i will move on to the next part because i believe users can log in and need to come back to the logout bug later

@drebel drebel added the enhancement New feature or request label Dec 16, 2023
@drebel drebel added this to the Rough Backend milestone Dec 16, 2023
@drebel drebel self-assigned this Dec 16, 2023
@drebel drebel linked an issue Dec 16, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setup logout controller
1 participant