Skip to content

Node.js based forum software built for the modern web

fix: crash if csrfToken does not exist

Barış Soner Uşaklıa3c8d4562611
diff --git a/src/routes/authentication.js b/src/routes/authentication.js
index 1f26c23980..c2b238f7d5 100644
--- a/src/routes/authentication.js
+++ b/src/routes/authentication.js
@@ -67,7 +67,7 @@ Auth.reloadRoutes = async function (params) {
loginStrategies.forEach(function (strategy) {
if (strategy.url) {
router.get(strategy.url, Auth.middleware.applyCSRF, function (req, res, next) {
- req.session.ssoState = req.csrfToken();
+ req.session.ssoState = req.csrfToken && req.csrfToken();
passport.authenticate(strategy.name, {
scope: strategy.scope,
prompt: strategy.prompt || undefined,