0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added a middleware to handle signin via a GET

no-issue

This also adds a basic check before handing of to the members-ssr
module, this should make logs a little less noisy and only log warnings
if a token was passed and that token was invalid/incorrect.
This commit is contained in:
Fabien O'Carroll 2019-09-16 15:59:10 +08:00
parent 0e60b5dea4
commit 73bc3ec388

View file

@ -176,6 +176,22 @@ module.exports = function setupSiteApp(options = {}) {
next();
});
});
siteApp.use(async function (req, res, next) {
if (!labsService.isSet('members')) {
return next();
}
if (!req.url.includes('token=')) {
return next();
}
try {
const member = await membersService.ssr.exchangeTokenForSession(req, res);
req.member = member;
next();
} catch (err) {
common.logging.warn(err.message);
return next();
}
});
siteApp.use(function (req, res, next) {
res.locals.member = req.member;
next();