mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
ee47dd4dae
no issue - adds new router to the frontend for handling unsubscribe - default template lives in `core/server/frontend/views/unsubscribe.hbs` - `{{error}}` is present and contains the error message when unsubscribe fails - `{{member}}` is present and contains the member email - updated unsubscribe url to match the new format
32 lines
923 B
JavaScript
32 lines
923 B
JavaScript
const debug = require('ghost-ignition').debug('services:routing:controllers:unsubscribe');
|
|
const path = require('path');
|
|
const megaService = require('../../../../server/services/mega');
|
|
const labsService = require('../../../../server/services/labs');
|
|
const helpers = require('../../../services/routing/helpers');
|
|
|
|
module.exports = async function unsubscribeController(req, res, next) {
|
|
debug('unsubscribeController');
|
|
|
|
if (!labsService.isSet('members')) {
|
|
return next();
|
|
}
|
|
|
|
let data = {};
|
|
|
|
try {
|
|
data.member = await megaService.mega.handleUnsubscribeRequest(req);
|
|
} catch (err) {
|
|
data.error = err.message;
|
|
}
|
|
|
|
const templateName = 'unsubscribe';
|
|
|
|
res.routerOptions = {
|
|
type: 'custom',
|
|
templates: templateName,
|
|
defaultTemplate: path.resolve(__dirname, '../../../views/', templateName)
|
|
};
|
|
|
|
return helpers.renderer(req, res, data);
|
|
};
|