From 531e217b82b2fb755358ecc6a909dc3689f4cd52 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Mon, 16 Sep 2019 15:57:11 +0800 Subject: [PATCH] Protected members middleware with a labs check no-issue This would have been creating a lot of noisy logs for sites without members enabled. --- core/server/web/site/app.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/server/web/site/app.js b/core/server/web/site/app.js index 39ef27a7de..d161777e78 100644 --- a/core/server/web/site/app.js +++ b/core/server/web/site/app.js @@ -11,6 +11,7 @@ const apps = require('../../services/apps'); const constants = require('../../lib/constants'); const storage = require('../../adapters/storage'); const urlService = require('../../../frontend/services/url'); +const labsService = require('../../services/labs'); const urlUtils = require('../../lib/url-utils'); const sitemapHandler = require('../../../frontend/services/sitemap/handler'); const themeMiddleware = require('../../../frontend/services/themes').middleware; @@ -162,6 +163,10 @@ module.exports = function setupSiteApp(options = {}) { }); }); siteApp.use(function (req, res, next) { + if (!labsService.isSet('members')) { + req.member = null; + return next(); + } membersService.ssr.getMemberDataFromSession(req, res).then((member) => { req.member = member; next();