diff --git a/src/server/routes/user.js b/src/server/routes/user.js index 66cfdcb..9e08db6 100644 --- a/src/server/routes/user.js +++ b/src/server/routes/user.js @@ -11,9 +11,16 @@ export default function userRoutes(app) { app.get('/auth/reddit/callback', (req, res, next) => { if (req.query.state === req.session.state) { passport.authenticate('reddit', { - successRedirect: '/', + successRedirect: '/chat', failureRedirect: '/login', - })(req, res, next); + })(req, res, (error) => { + if (error) { + next(error); + return; + } + delete req.session.state; + req.session.save(next); + }); } else { res.status(403).end('Forbidden: state mismatch');