Tied consent warning to session.
This commit is contained in:
parent
be4d025505
commit
bd77d4347d
|
@ -6,7 +6,8 @@
|
||||||
<Warning
|
<Warning
|
||||||
v-if="showWarning"
|
v-if="showWarning"
|
||||||
class="warning-container"
|
class="warning-container"
|
||||||
@enter="closeWarning"
|
@enter="setConsent(true)"
|
||||||
|
@leave="setConsent(false)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<transition name="slide">
|
<transition name="slide">
|
||||||
|
@ -41,9 +42,11 @@ function toggleSidebar(state) {
|
||||||
this.showSidebar = typeof state === 'boolean' ? state : !this.showSidebar;
|
this.showSidebar = typeof state === 'boolean' ? state : !this.showSidebar;
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeWarning() {
|
async function setConsent(consent) {
|
||||||
|
if (consent) {
|
||||||
this.showWarning = false;
|
this.showWarning = false;
|
||||||
sessionStorage.setItem('warning', 'warned');
|
await this.$store.dispatch('setConsent', true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mounted() {
|
function mounted() {
|
||||||
|
@ -61,7 +64,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showSidebar: false,
|
showSidebar: false,
|
||||||
showWarning: sessionStorage.getItem('warning') !== 'warned',
|
showWarning: !window.env.consent,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -72,7 +75,7 @@ export default {
|
||||||
mounted,
|
mounted,
|
||||||
methods: {
|
methods: {
|
||||||
toggleSidebar,
|
toggleSidebar,
|
||||||
closeWarning,
|
setConsent,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
<a
|
<a
|
||||||
href="https://www.google.com"
|
href="https://www.google.com"
|
||||||
class="button leave"
|
class="button leave"
|
||||||
|
@click="$emit('leave')"
|
||||||
>Leave</a>
|
>Leave</a>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { graphql } from '../api';
|
import { graphql, post } from '../api';
|
||||||
import { curateRelease, curateActor } from '../curate';
|
import { curateRelease, curateActor } from '../curate';
|
||||||
|
|
||||||
function initUiActions(_store, _router) {
|
function initUiActions(_store, _router) {
|
||||||
|
@ -26,6 +26,12 @@ function initUiActions(_store, _router) {
|
||||||
localStorage.setItem('sfw', sfw);
|
localStorage.setItem('sfw', sfw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function setConsent({ _commit }, consent) {
|
||||||
|
const res = await post('/consent', consent);
|
||||||
|
|
||||||
|
return res.ok;
|
||||||
|
}
|
||||||
|
|
||||||
async function search({ _commit }, { query, limit = 20 }) {
|
async function search({ _commit }, { query, limit = 20 }) {
|
||||||
const res = await graphql(`
|
const res = await graphql(`
|
||||||
query SearchReleases(
|
query SearchReleases(
|
||||||
|
@ -188,6 +194,7 @@ function initUiActions(_store, _router) {
|
||||||
setRange,
|
setRange,
|
||||||
setBatch,
|
setBatch,
|
||||||
setSfw,
|
setSfw,
|
||||||
|
setConsent,
|
||||||
setTheme,
|
setTheme,
|
||||||
fetchStats,
|
fetchStats,
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,6 +10,14 @@ module.exports = {
|
||||||
port: 5000,
|
port: 5000,
|
||||||
sfwHost: '0.0.0.0',
|
sfwHost: '0.0.0.0',
|
||||||
sfwPort: 5001,
|
sfwPort: 5001,
|
||||||
|
session: {
|
||||||
|
secret: '12345678abcdefghij',
|
||||||
|
resave: false,
|
||||||
|
saveUninitialized: false,
|
||||||
|
cookie: {
|
||||||
|
secure: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
exclude: {
|
exclude: {
|
||||||
channels: [
|
channels: [
|
||||||
|
|
|
@ -2918,6 +2918,15 @@
|
||||||
"integrity": "sha512-KbS1Y0jMtyPgIxjO7ZzMAuUpAKMt1SzCL9fsrKsX6b0zJPTaT0SiSPmewwVZg9UAO83HVIlEhZF84LIjZ0lmAw==",
|
"integrity": "sha512-KbS1Y0jMtyPgIxjO7ZzMAuUpAKMt1SzCL9fsrKsX6b0zJPTaT0SiSPmewwVZg9UAO83HVIlEhZF84LIjZ0lmAw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"connect-session-knex": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/connect-session-knex/-/connect-session-knex-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-1QaN7k9NjXcXmE+MHoH7YeAGcUGdqZzpIKb8otHgqFQ2IYLhoeGG/o1PP2cdJZNgcr1gPHJEL8hmKIx8XosOhg==",
|
||||||
|
"requires": {
|
||||||
|
"bluebird": "^3.7.2",
|
||||||
|
"knex": "^0.21.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"console-browserify": {
|
"console-browserify": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz",
|
||||||
|
@ -4483,6 +4492,46 @@
|
||||||
"object-assign": "^4.1.1"
|
"object-assign": "^4.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"express-session": {
|
||||||
|
"version": "1.17.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/express-session/-/express-session-1.17.1.tgz",
|
||||||
|
"integrity": "sha512-UbHwgqjxQZJiWRTMyhvWGvjBQduGCSBDhhZXYenziMFjxst5rMV+aJZ6hKPHZnPyHGsrqRICxtX8jtEbm/z36Q==",
|
||||||
|
"requires": {
|
||||||
|
"cookie": "0.4.0",
|
||||||
|
"cookie-signature": "1.0.6",
|
||||||
|
"debug": "2.6.9",
|
||||||
|
"depd": "~2.0.0",
|
||||||
|
"on-headers": "~1.0.2",
|
||||||
|
"parseurl": "~1.3.3",
|
||||||
|
"safe-buffer": "5.2.0",
|
||||||
|
"uid-safe": "~2.1.5"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"debug": {
|
||||||
|
"version": "2.6.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||||
|
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||||
|
"requires": {
|
||||||
|
"ms": "2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"depd": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw=="
|
||||||
|
},
|
||||||
|
"ms": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||||
|
},
|
||||||
|
"safe-buffer": {
|
||||||
|
"version": "5.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
|
||||||
|
"integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"extend": {
|
"extend": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/extend/-/extend-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/extend/-/extend-2.0.2.tgz",
|
||||||
|
@ -8179,6 +8228,11 @@
|
||||||
"ee-first": "1.1.1"
|
"ee-first": "1.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"on-headers": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA=="
|
||||||
|
},
|
||||||
"once": {
|
"once": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||||
|
@ -9090,6 +9144,11 @@
|
||||||
"integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=",
|
"integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"random-bytes": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs="
|
||||||
|
},
|
||||||
"randombytes": {
|
"randombytes": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
|
||||||
|
@ -11454,6 +11513,14 @@
|
||||||
"is-typedarray": "^1.0.0"
|
"is-typedarray": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"uid-safe": {
|
||||||
|
"version": "2.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz",
|
||||||
|
"integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==",
|
||||||
|
"requires": {
|
||||||
|
"random-bytes": "~1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"umzug": {
|
"umzug": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/umzug/-/umzug-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/umzug/-/umzug-2.2.0.tgz",
|
||||||
|
|
|
@ -85,6 +85,7 @@
|
||||||
"cheerio": "^1.0.0-rc.3",
|
"cheerio": "^1.0.0-rc.3",
|
||||||
"cli-confirm": "^1.0.1",
|
"cli-confirm": "^1.0.1",
|
||||||
"config": "^3.2.5",
|
"config": "^3.2.5",
|
||||||
|
"connect-session-knex": "^2.0.0",
|
||||||
"csv-stringify": "^5.3.6",
|
"csv-stringify": "^5.3.6",
|
||||||
"dayjs": "^1.8.21",
|
"dayjs": "^1.8.21",
|
||||||
"dompurify": "^2.0.11",
|
"dompurify": "^2.0.11",
|
||||||
|
@ -92,6 +93,7 @@
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-promise-router": "^3.0.3",
|
"express-promise-router": "^3.0.3",
|
||||||
"express-react-views": "^0.11.0",
|
"express-react-views": "^0.11.0",
|
||||||
|
"express-session": "^1.17.1",
|
||||||
"face-api.js": "^0.22.2",
|
"face-api.js": "^0.22.2",
|
||||||
"faker": "^5.1.0",
|
"faker": "^5.1.0",
|
||||||
"file-type": "^14.1.4",
|
"file-type": "^14.1.4",
|
||||||
|
|
|
@ -8,5 +8,5 @@ module.exports = knex({
|
||||||
connection: config.database,
|
connection: config.database,
|
||||||
// performance overhead, don't use asyncStackTraces in production
|
// performance overhead, don't use asyncStackTraces in production
|
||||||
asyncStackTraces: process.env.NODE_ENV === 'development',
|
asyncStackTraces: process.env.NODE_ENV === 'development',
|
||||||
debug: process.env.NODE_ENV === 'development',
|
// debug: process.env.NODE_ENV === 'development',
|
||||||
});
|
});
|
||||||
|
|
10
src/media.js
10
src/media.js
|
@ -126,7 +126,7 @@ function toBaseSource(rawSource) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function baseSourceToBaseMedia(baseSource, role, metadata) {
|
function baseSourceToBaseMedia(baseSource, role, metadata, options) {
|
||||||
if (Array.isArray(baseSource)) {
|
if (Array.isArray(baseSource)) {
|
||||||
if (baseSource.length > 0) {
|
if (baseSource.length > 0) {
|
||||||
return {
|
return {
|
||||||
|
@ -134,6 +134,7 @@ function baseSourceToBaseMedia(baseSource, role, metadata) {
|
||||||
id: nanoid(),
|
id: nanoid(),
|
||||||
role,
|
role,
|
||||||
sources: baseSource,
|
sources: baseSource,
|
||||||
|
...options,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +147,7 @@ function baseSourceToBaseMedia(baseSource, role, metadata) {
|
||||||
id: nanoid(),
|
id: nanoid(),
|
||||||
role,
|
role,
|
||||||
sources: [baseSource],
|
sources: [baseSource],
|
||||||
|
...options,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,6 +301,8 @@ async function storeImageFile(media, hashDir, hashSubDir, filename, filedir, fil
|
||||||
const info = await image.metadata();
|
const info = await image.metadata();
|
||||||
const isProcessed = media.meta.subtype !== 'jpeg' || media.process;
|
const isProcessed = media.meta.subtype !== 'jpeg' || media.process;
|
||||||
|
|
||||||
|
console.log(media);
|
||||||
|
|
||||||
if (media.process) {
|
if (media.process) {
|
||||||
Object.entries(media.process).forEach(([operation, options]) => {
|
Object.entries(media.process).forEach(([operation, options]) => {
|
||||||
if (image[operation]) {
|
if (image[operation]) {
|
||||||
|
@ -727,9 +731,9 @@ async function associateAvatars(profiles) {
|
||||||
? {
|
? {
|
||||||
...profile,
|
...profile,
|
||||||
avatarBaseMedia: toBaseMedias([profile.avatar], 'avatars', {
|
avatarBaseMedia: toBaseMedias([profile.avatar], 'avatars', {
|
||||||
credit: (profile.credit !== undefined && (profile.network?.name || profile.site?.name)) || null,
|
credit: profile.credit || profile.entity?.name || null,
|
||||||
scraper: profile.scraper || null,
|
scraper: profile.scraper || null,
|
||||||
})[0],
|
}, { stats: true })[0],
|
||||||
}
|
}
|
||||||
: profile
|
: profile
|
||||||
));
|
));
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function setConsent(req, res) {
|
||||||
|
req.session.consent = !!req.body;
|
||||||
|
res.status(204).send();
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = setConsent;
|
|
@ -6,12 +6,15 @@ const express = require('express');
|
||||||
const { postgraphile } = require('postgraphile');
|
const { postgraphile } = require('postgraphile');
|
||||||
const Router = require('express-promise-router');
|
const Router = require('express-promise-router');
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
|
const session = require('express-session');
|
||||||
|
const KnexSessionStore = require('connect-session-knex')(session);
|
||||||
|
|
||||||
const PgConnectionFilterPlugin = require('postgraphile-plugin-connection-filter');
|
const PgConnectionFilterPlugin = require('postgraphile-plugin-connection-filter');
|
||||||
const PgSimplifyInflectorPlugin = require('@graphile-contrib/pg-simplify-inflector');
|
const PgSimplifyInflectorPlugin = require('@graphile-contrib/pg-simplify-inflector');
|
||||||
const PgOrderByRelatedPlugin = require('@graphile-contrib/pg-order-by-related');
|
const PgOrderByRelatedPlugin = require('@graphile-contrib/pg-order-by-related');
|
||||||
|
|
||||||
const logger = require('../logger')(__filename);
|
const logger = require('../logger')(__filename);
|
||||||
|
const knex = require('../knex');
|
||||||
const { ActorPlugins, SitePlugins, ReleasePlugins } = require('./plugins/plugins');
|
const { ActorPlugins, SitePlugins, ReleasePlugins } = require('./plugins/plugins');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -35,9 +38,12 @@ const {
|
||||||
fetchTags,
|
fetchTags,
|
||||||
} = require('./tags');
|
} = require('./tags');
|
||||||
|
|
||||||
|
const setConsent = require('./consent');
|
||||||
|
|
||||||
async function initServer() {
|
async function initServer() {
|
||||||
const app = express();
|
const app = express();
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
const store = new KnexSessionStore({ knex });
|
||||||
|
|
||||||
const connectionString = `postgres://${config.database.user}:${config.database.password}@${config.database.host}:5432/${config.database.database}`;
|
const connectionString = `postgres://${config.database.user}:${config.database.password}@${config.database.host}:5432/${config.database.database}`;
|
||||||
|
|
||||||
|
@ -77,6 +83,7 @@ async function initServer() {
|
||||||
});
|
});
|
||||||
|
|
||||||
router.use(bodyParser.json({ strict: false }));
|
router.use(bodyParser.json({ strict: false }));
|
||||||
|
router.use(session({ ...config.web.session, store }));
|
||||||
|
|
||||||
router.get('/api/scenes', fetchScenes);
|
router.get('/api/scenes', fetchScenes);
|
||||||
router.get('/api/scenes/:releaseId', fetchScene);
|
router.get('/api/scenes/:releaseId', fetchScene);
|
||||||
|
@ -103,10 +110,13 @@ async function initServer() {
|
||||||
router.get('/api/tags', fetchTags);
|
router.get('/api/tags', fetchTags);
|
||||||
router.get('/api/tags/:tagId', fetchTag);
|
router.get('/api/tags/:tagId', fetchTag);
|
||||||
|
|
||||||
|
router.post('/api/consent', setConsent);
|
||||||
|
|
||||||
router.get('*', (req, res) => {
|
router.get('*', (req, res) => {
|
||||||
res.render(path.join(__dirname, '../../assets/index.ejs'), {
|
res.render(path.join(__dirname, '../../assets/index.ejs'), {
|
||||||
env: JSON.stringify({
|
env: JSON.stringify({
|
||||||
sfw: !!req.headers.sfw || Object.prototype.hasOwnProperty.call(req.query, 'sfw'),
|
sfw: !!req.headers.sfw || Object.prototype.hasOwnProperty.call(req.query, 'sfw'),
|
||||||
|
consent: !!req.session.consent,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue