mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
Wired up middleware to handle unsubscribing
no-issue
This commit is contained in:
parent
73b00e77c2
commit
a7e7f74f8b
@ -15,6 +15,7 @@ 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;
|
||||
const megaService = require('../../services/mega');
|
||||
const membersService = require('../../services/members');
|
||||
const siteRoutes = require('./routes');
|
||||
const shared = require('../shared');
|
||||
@ -189,6 +190,21 @@ module.exports = function setupSiteApp(options = {}) {
|
||||
return next();
|
||||
}
|
||||
});
|
||||
siteApp.use(async function (req, res, next) {
|
||||
if (!labsService.isSet('members')) {
|
||||
return next();
|
||||
}
|
||||
if (!req.url.includes('unsubscribe=')) {
|
||||
return next();
|
||||
}
|
||||
try {
|
||||
await megaService.mega.handleUnsubscribeRequest(req);
|
||||
next();
|
||||
} catch (err) {
|
||||
common.logging.warn(err.message);
|
||||
return next();
|
||||
}
|
||||
});
|
||||
siteApp.use(function (req, res, next) {
|
||||
res.locals.member = req.member;
|
||||
next();
|
||||
|
Loading…
Reference in New Issue
Block a user