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:
parent
0e60b5dea4
commit
73bc3ec388
1 changed files with 16 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue