Consent page redirects to original URL.

This commit is contained in:
DebaucheryLibrarian 2024-06-04 02:14:45 +02:00
parent d31c8e9832
commit 9a9e1da3cf
1 changed files with 5 additions and 2 deletions

View File

@ -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;
}