diff --git a/locale/pl/config.suml b/locale/pl/config.suml index b60d5d9a..6768545e 100644 --- a/locale/pl/config.suml +++ b/locale/pl/config.suml @@ -547,6 +547,7 @@ census: - ['osobą niebinarną'] - ['osobą cispłciową'] - ['binarną osobą transpłciową'] + # - ['nie wiem'] - type: 'number' min: 1900 diff --git a/locale/pl/translations.suml b/locale/pl/translations.suml index 6608cad0..2f5586b1 100644 --- a/locale/pl/translations.suml +++ b/locale/pl/translations.suml @@ -966,7 +966,7 @@ census: By uniknąć tendencyjności, kolejność propozycji jest losowa. agree: > Wyrażam zgodę na przetwarzanie moich odpowiedzi - oraz na użycie zanonimizowanej wersji mojego adresu IP oraz fingerprintu przeglądarki + oraz na użycie mojego adresu IP oraz fingerprintu przeglądarki do przeciwdziałania wandalizmom i spamowi. Dane te nie są w stanie zidentyfikować żadnej osoby, zostaną użyte wyłącznie w celu zapewnienia unikalności odpowiedzi diff --git a/migrations/022-census-suspicious.sql b/migrations/022-census-suspicious.sql new file mode 100644 index 00000000..bc7f971f --- /dev/null +++ b/migrations/022-census-suspicious.sql @@ -0,0 +1,8 @@ +-- Up + +ALTER TABLE census ADD COLUMN ip TEXT NULL DEFAULT NULL; +ALTER TABLE census ADD COLUMN userAgent TEXT NULL DEFAULT NULL; +ALTER TABLE census ADD COLUMN acceptLanguage TEXT NULL DEFAULT NULL; +ALTER TABLE census ADD COLUMN suspicious INTEGER NOT NULL DEFAULT 0; + +-- Down diff --git a/routes/census.vue b/routes/census.vue index ba6fd3e9..08b8274b 100644 --- a/routes/census.vue +++ b/routes/census.vue @@ -168,6 +168,11 @@ countResponses, }; }, + mounted() { + if (process.client) { + this.finished = !!parseInt(window.localStorage.getItem('census-finished') || 0); + } + }, methods: { startSurvey() { this.q = 0; @@ -224,6 +229,7 @@ writins: JSON.stringify(this.writins), }); this.finished = true; + window.localStorage.setItem('census-finished', '1'); } this.$nextTick(() => { if (this.$refs.questionform) { diff --git a/server/routes/census.js b/server/routes/census.js index 5ea90119..c695c381 100644 --- a/server/routes/census.js +++ b/server/routes/census.js @@ -38,19 +38,21 @@ router.get('/census/finished', async (req, res) => { }); router.post('/census/submit', async (req, res) => { - if (await hasFinished(req)) { - return res.status(401).json({error: 'Unauthorised'}); - } + const suspicious = await hasFinished(req); const id = ulid(); - await req.db.get(SQL`INSERT INTO census (id, locale, edition, userId, fingerprint, answers, writins) VALUES ( + await req.db.get(SQL`INSERT INTO census (id, locale, edition, userId, fingerprint, answers, writins, ip, userAgent, acceptLanguage, suspicious) VALUES ( ${id}, ${req.config.locale}, ${req.config.census.edition}, ${req.user ? req.user.id : null}, ${buildFingerprint(req)}, ${req.body.answers}, - ${req.body.writins} + ${req.body.writins}, + ${req.ip}, + ${req.headers['user-agent']}, + ${req.headers['accept-language']}, + ${suspicious} )`); return res.json(id);