From 350c5d143ad533889c0acd8efb127adad09a3c6d Mon Sep 17 00:00:00 2001 From: cha0s Date: Sat, 18 Jul 2020 17:07:03 -0500 Subject: [PATCH] fix: state cleanup --- src/server/routes/user.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/server/routes/user.js b/src/server/routes/user.js index 9e08db6..b02813d 100644 --- a/src/server/routes/user.js +++ b/src/server/routes/user.js @@ -10,16 +10,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: '/chat', - failureRedirect: '/login', - })(req, res, (error) => { + delete req.session.state; + req.session.save((error) => { if (error) { next(error); return; } - delete req.session.state; - req.session.save(next); + passport.authenticate('reddit', { + successRedirect: '/chat', + failureRedirect: '/login', + })(req, res, next); }); } else {