Consent page redirects to original URL.
This commit is contained in:
parent
d31c8e9832
commit
9a9e1da3cf
|
@ -1,4 +1,6 @@
|
||||||
export default function consentHandler(req, res, next) {
|
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')) {
|
if (Object.hasOwn(req.query, 'lgbt')) {
|
||||||
const lgbtFilters = (req.tagFilter || []).filter((tag) => !['gay', 'bisexual', 'transsexual'].includes(tag));
|
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')) {
|
if (Object.hasOwn(req.query, 'consent')) {
|
||||||
req.session.hasConsent = true; // eslint-disable-line no-param-reassign
|
req.session.hasConsent = true; // eslint-disable-line no-param-reassign
|
||||||
res.redirect(req.path);
|
res.redirect(redirect || req.path);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!req.path.includes('/consent') && !req.session?.hasConsent) {
|
if (!req.path.includes('/consent') && !req.session?.hasConsent) {
|
||||||
res.redirect('/consent');
|
res.redirect(`/consent?redirect=${req.originalUrl === '/' ? '' : encodeURIComponent(req.originalUrl) }`);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue