Consent page redirects to original URL.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
export default function consentHandler(req, res, next) {
|
||||
const redirect = req.headers.referer && new URL(req.headers.referer).searchParams.get('redirect');
|
||||
|
||||
if (Object.hasOwn(req.query, 'lgbt')) {
|
||||
const lgbtFilters = (req.tagFilter || []).filter((tag) => !['gay', 'bisexual', 'transsexual'].includes(tag));
|
||||
|
||||
@@ -15,13 +17,14 @@ export default function consentHandler(req, res, next) {
|
||||
|
||||
if (Object.hasOwn(req.query, 'consent')) {
|
||||
req.session.hasConsent = true; // eslint-disable-line no-param-reassign
|
||||
res.redirect(req.path);
|
||||
res.redirect(redirect || req.path);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!req.path.includes('/consent') && !req.session?.hasConsent) {
|
||||
res.redirect('/consent');
|
||||
res.redirect(`/consent?redirect=${req.originalUrl === '/' ? '' : encodeURIComponent(req.originalUrl) }`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user