fix: state cleanup

This commit is contained in:
cha0s 2020-07-18 17:07:03 -05:00
parent d1b3ee0009
commit 350c5d143a

View File

@ -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 {