Commit e05b61b6 authored by Adrien Luxey's avatar Adrien Luxey
Browse files

Added a 'captcha'

parent 13db31d9
......@@ -12,14 +12,15 @@ WORKDIR /usr/src/app
EXPOSE 5000
COPY --from=builder /usr/src/app/dist/*.whl .
ENV FLASK_SECRET_KEY=override-when-launching-docker-run
ENV FLASK_ENV=production
COPY translations translations
RUN set -ex \
&& pip --no-cache-dir install *.whl waitress;
COPY --from=builder /usr/src/app/dist/*.whl .
ENV FLASK_SECRET_KEY=override-when-launching-run
ENV FLASK_ENV=production
RUN set -ex \
&& pip --no-cache-dir install *.whl waitress;
CMD waitress-serve --port 5000 --call 'd2d_survey:create_app'
......@@ -10,6 +10,9 @@ def handle_form():
if request.method == 'GET':
return render_template(f'static/form.html', guid=token_hex(GUID_NBYTES))
elif request.method == 'POST':
if not "d2dsurvey.net" in request.form['captcha'].lower():
flash(lazy_gettext("From our point of view, you are a robot: you failed the anti-robot question."), 'error')
return render_template(f'static/form.html', guid=request.form['guid'])
if guid_exists(request.form['guid']):
return redirect(url_for('frontend.static', page='thank_you'))
......@@ -34,6 +37,7 @@ def save_results():
current_app.config['OUTPUT_DIR'], f"{form['guid']}.json")
with open(fn, 'w') as f:
del form['guid']
form['date'] = datetime.utcnow().isoformat()
form['ip'] = request.remote_addr
form['user_agent'] = request.user_agent.string
......
......@@ -379,8 +379,17 @@
</div>
</fieldset>
{### SECURITY ###}
<h3>{{_("Anti-robot question")}}</h3>
<fieldset>
<legend class="asterisk">{{ _("What is the address of this site? (hint: it ends with <code>.net</code>)") }}</legend>
<input type="text" name="captcha" required>
</fieldset>
<input type="hidden" name="guid" value="{{ guid }}">
{### SUBMIT ###}
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: adrien.luxe@inria.fr\n"
"POT-Creation-Date: 2021-11-04 13:13+0100\n"
"POT-Creation-Date: 2021-11-04 14:06+0100\n"
"PO-Revision-Date: 2021-10-26 13:49+0200\n"
"Last-Translator: Adrien Luxey <adrien.luxe@inria.fr>\n"
"Language: fr\n"
......@@ -18,7 +18,15 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"
#: d2d_survey/survey.py:19
#: d2d_survey/survey.py:14
msgid ""
"From our point of view, you are a robot: you failed the anti-robot "
"question."
msgstr ""
"Il semblerait que vous soyez un robot : vous vous êtes trompé à la "
"question anti-robot."
#: d2d_survey/survey.py:22
msgid "An error occured while saving your results: "
msgstr "Une erreur s'est produite lors de l'enregistrement de vos réponses : "
......@@ -436,7 +444,17 @@ msgstr ""
"adresse e-mail. En effet, vos réponses seront rendues publiquement "
"accessibles au nom de la reproductibilité de la recherche."
#: d2d_survey/templates/static/form.html:388
#: d2d_survey/templates/static/form.html:386
msgid "Anti-robot question"
msgstr "Question anti-robot"
#: d2d_survey/templates/static/form.html:389
msgid "What is the address of this site? (hint: it ends with <code>.net</code>)"
msgstr ""
"Quelle est l'adresse de ce site ? (indice : elle termine par "
"<code>.net</code>)"
#: d2d_survey/templates/static/form.html:397
msgid "Submit"
msgstr "Soumettre"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment