Using generic session ID variable for to determine consent warning, rather than dedicated property.
This commit is contained in:
parent
4a1faa0074
commit
27e5583849
|
@ -45,7 +45,7 @@ function toggleSidebar(state) {
|
||||||
async function setConsent(consent) {
|
async function setConsent(consent) {
|
||||||
if (consent) {
|
if (consent) {
|
||||||
this.showWarning = false;
|
this.showWarning = false;
|
||||||
await this.$store.dispatch('setConsent', true);
|
localStorage.setItem('consent', window.env.sessionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showSidebar: false,
|
showSidebar: false,
|
||||||
showWarning: !window.env.consent,
|
showWarning: localStorage.getItem('consent') !== window.env.sessionId,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { graphql, post } from '../api';
|
import { graphql } from '../api';
|
||||||
import { curateRelease, curateActor } from '../curate';
|
import { curateRelease, curateActor } from '../curate';
|
||||||
|
|
||||||
function initUiActions(_store, _router) {
|
function initUiActions(_store, _router) {
|
||||||
|
@ -26,12 +26,6 @@ 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(
|
||||||
|
@ -194,7 +188,6 @@ function initUiActions(_store, _router) {
|
||||||
setRange,
|
setRange,
|
||||||
setBatch,
|
setBatch,
|
||||||
setSfw,
|
setSfw,
|
||||||
setConsent,
|
|
||||||
setTheme,
|
setTheme,
|
||||||
fetchStats,
|
fetchStats,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function setConsent(req, res) {
|
|
||||||
req.session.consent = !!req.body;
|
|
||||||
res.status(204).send();
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = setConsent;
|
|
|
@ -8,6 +8,7 @@ const Router = require('express-promise-router');
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
const session = require('express-session');
|
const session = require('express-session');
|
||||||
const KnexSessionStore = require('connect-session-knex')(session);
|
const KnexSessionStore = require('connect-session-knex')(session);
|
||||||
|
const nanoid = require('nanoid');
|
||||||
|
|
||||||
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');
|
||||||
|
@ -38,8 +39,6 @@ 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();
|
||||||
|
@ -85,6 +84,12 @@ async function initServer() {
|
||||||
router.use(bodyParser.json({ strict: false }));
|
router.use(bodyParser.json({ strict: false }));
|
||||||
router.use(session({ ...config.web.session, store }));
|
router.use(session({ ...config.web.session, store }));
|
||||||
|
|
||||||
|
router.use((req, res, next) => {
|
||||||
|
req.session.safeId = req.session.safeId || nanoid();
|
||||||
|
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/api/scenes', fetchScenes);
|
router.get('/api/scenes', fetchScenes);
|
||||||
router.get('/api/scenes/:releaseId', fetchScene);
|
router.get('/api/scenes/:releaseId', fetchScene);
|
||||||
router.get('/api/scenes/:releaseId/poster', fetchScenePoster);
|
router.get('/api/scenes/:releaseId/poster', fetchScenePoster);
|
||||||
|
@ -110,13 +115,11 @@ 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,
|
sessionId: req.session.safeId,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue