From ef8b51d6d46768f0a5c0c6ad2212972cd5a1445a Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Sat, 5 Dec 2020 16:16:24 +0100 Subject: [PATCH] add dumb captcha to reduce signup spam problems --- src/bornhack/forms.py | 16 ++++++++++++++++ src/bornhack/settings.py | 3 +++ 2 files changed, 19 insertions(+) create mode 100644 src/bornhack/forms.py diff --git a/src/bornhack/forms.py b/src/bornhack/forms.py new file mode 100644 index 00000000..9aa8b81b --- /dev/null +++ b/src/bornhack/forms.py @@ -0,0 +1,16 @@ +from django import forms +from django.core.exceptions import ValidationError + + +class AllAuthSignupCaptchaForm(forms.Form): + first_bornhack_year = forms.CharField( + initial="", + help_text="Please help us prevent a few bot signups by telling us the year of the first BornHack.", + ) + + def clean_first_bornhack_year(self): + if self.cleaned_data["first_bornhack_year"] != "2016": + raise ValidationError("To error is human. Please try to be less human! :)") + + def signup(self, request, user): + user.save() diff --git a/src/bornhack/settings.py b/src/bornhack/settings.py index 4e4c9ec3..da1e8781 100644 --- a/src/bornhack/settings.py +++ b/src/bornhack/settings.py @@ -198,3 +198,6 @@ ECONOMY_TEAM_NAME = "Economy" # we have some large formsets sometimes DATA_UPLOAD_MAX_NUMBER_FIELDS = 5000 + +# use captcha form +ACCOUNT_SIGNUP_FORM_CLASS = "bornhack.forms.AllAuthSignupCaptchaForm"