From 3717df610acb8fc63a3b8c1cb65d3a5898e6f0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 3 Jun 2021 17:11:25 -0400 Subject: [PATCH] fix: don't crash if session doesn't exist --- src/routes/authentication.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/routes/authentication.js b/src/routes/authentication.js index b8373296cf..ca7b98d870 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -131,12 +131,16 @@ Auth.reloadRoutes = async function (params) { passport.authenticate(strategy.name, (err, user) => { if (err) { - delete req.session.registration; + if (req.session && req.session.registration) { + delete req.session.registration; + } return next(err); } if (!user) { - delete req.session.registration; + if (req.session && req.session.registration) { + delete req.session.registration; + } return helpers.redirect(res, strategy.failureUrl !== undefined ? strategy.failureUrl : '/login'); }