0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Protected members middleware with a labs check

no-issue

This would have been creating a lot of noisy logs for sites without
members enabled.
This commit is contained in:
Fabien O'Carroll 2019-09-16 15:57:11 +08:00
parent a3940ef9db
commit 531e217b82

View file

@ -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();