mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
refs https://github.com/TryGhost/Team/issues/1616 - Removed all GA feature flags - Removed `tweetGridCard` alpha flag - Changes to `members-api` and `members-importer` packages: https://github.com/TryGhost/Members/compare/%40tryghost/members-api%408.1.1...%40tryghost/members-api%408.1.2
24 lines
786 B
JavaScript
24 lines
786 B
JavaScript
const debug = require('@tryghost/debug')('services:routing:controllers:unsubscribe');
|
|
const url = require('url');
|
|
|
|
const urlUtils = require('../../../../shared/url-utils');
|
|
|
|
module.exports = async function unsubscribeController(req, res) {
|
|
debug('unsubscribeController');
|
|
|
|
const {query} = url.parse(req.url, true);
|
|
|
|
if (!query || !query.uuid) {
|
|
res.writeHead(400);
|
|
return res.end('Email address not found.');
|
|
}
|
|
|
|
const redirectUrl = new URL(urlUtils.urlFor('home', true));
|
|
redirectUrl.searchParams.append('uuid', query.uuid);
|
|
if (query.newsletter) {
|
|
redirectUrl.searchParams.append('newsletter', query.newsletter);
|
|
}
|
|
redirectUrl.searchParams.append('action', 'unsubscribe');
|
|
|
|
return res.redirect(302, redirectUrl.href);
|
|
};
|