diff --git a/.nvmrc b/.nvmrc index d5a1596..48b14e6 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20.10.0 +20.14.0 diff --git a/assets/consent.html b/assets/consent.html new file mode 100644 index 0000000..0409d5d --- /dev/null +++ b/assets/consent.html @@ -0,0 +1,198 @@ + + + + + traxxx - consent + + + + + +
+

+ contains sexually explicit content +

+ + +

+ +
+ Leave + + +
Enter
+
I prefer straight content
+
+ + +
Enter
+
Include gay, bi and trans content
+
+
+
+ + diff --git a/components/header/header.vue b/components/header/header.vue index abede01..2fd5353 100644 --- a/components/header/header.vue +++ b/components/header/header.vue @@ -234,7 +234,7 @@ function search() { async function logout() { await del('/session'); - navigate('/login', null, { redirect: true }); + navigate('/login?consent', null, { redirect: true }); // pass consent variable to reinstate in new session } function blurSearch(event) { diff --git a/public/img/logo.svg b/public/img/logo.svg new file mode 100644 index 0000000..37ff031 --- /dev/null +++ b/public/img/logo.svg @@ -0,0 +1,19 @@ + + + + + + + diff --git a/src/web/consent.js b/src/web/consent.js new file mode 100644 index 0000000..f7b083b --- /dev/null +++ b/src/web/consent.js @@ -0,0 +1,29 @@ +export default function consentHandler(req, res, next) { + if (Object.hasOwn(req.query, 'lgbt')) { + const lgbtFilters = (req.tagFilter || []).filter((tag) => !['gay', 'bisexual', 'transsexual'].includes(tag)); + + req.tagFilter = lgbtFilters; // eslint-disable-line no-param-reassign + res.cookie('tags', JSON.stringify(lgbtFilters)); + } + + if (Object.hasOwn(req.query, 'straight')) { + const straightFilters = Array.from(new Set([...(req.tagFilter || []), 'gay', 'bisexual', 'transsexual'])); + + req.tagFilter = straightFilters; // eslint-disable-line no-param-reassign + res.cookie('tags', JSON.stringify(straightFilters)); + } + + if (Object.hasOwn(req.query, 'consent')) { + req.session.hasConsent = true; // eslint-disable-line no-param-reassign + res.redirect(req.path); + + return; + } + + if (!req.path.includes('/consent') && !req.session?.hasConsent) { + res.redirect('/consent'); + return; + } + + next(); +} diff --git a/src/web/server.js b/src/web/server.js index b39e84a..5cb39be 100644 --- a/src/web/server.js +++ b/src/web/server.js @@ -1,4 +1,5 @@ import config from 'config'; +import path from 'path'; import express from 'express'; import boolParser from 'express-query-boolean'; import Router from 'express-promise-router'; @@ -13,6 +14,7 @@ import { renderPage } from 'vike/server'; // eslint-disable-line import/extensio import redis from '../redis.js'; import errorHandler from './error.js'; +import consentHandler from './consent.js'; import { fetchScenesApi } from './scenes.js'; import { fetchActorsApi } from './actors.js'; @@ -122,6 +124,12 @@ export default async function initServer() { router.use(viteDevMiddleware); } + router.use(consentHandler); + + router.get('/consent', (req, res) => { + res.sendFile(path.join(import.meta.dirname, '../../assets/consent.html')); + }); + // SESSION router.post('/api/session', loginApi); router.delete('/api/session', logoutApi);