refactor: redirect logged-in to chat & clear state
This commit is contained in:
parent
0aa134ee04
commit
619292b853
|
@ -11,9 +11,16 @@ export default function userRoutes(app) {
|
||||||
app.get('/auth/reddit/callback', (req, res, next) => {
|
app.get('/auth/reddit/callback', (req, res, next) => {
|
||||||
if (req.query.state === req.session.state) {
|
if (req.query.state === req.session.state) {
|
||||||
passport.authenticate('reddit', {
|
passport.authenticate('reddit', {
|
||||||
successRedirect: '/',
|
successRedirect: '/chat',
|
||||||
failureRedirect: '/login',
|
failureRedirect: '/login',
|
||||||
})(req, res, next);
|
})(req, res, (error) => {
|
||||||
|
if (error) {
|
||||||
|
next(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete req.session.state;
|
||||||
|
req.session.save(next);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res.status(403).end('Forbidden: state mismatch');
|
res.status(403).end('Forbidden: state mismatch');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user