add dumb captcha to reduce signup spam problems

This commit is contained in:
Thomas Steen Rasmussen 2020-12-05 16:16:24 +01:00
parent 35aa001289
commit ef8b51d6d4
2 changed files with 19 additions and 0 deletions

16
src/bornhack/forms.py Normal file
View file

@ -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()

View file

@ -198,3 +198,6 @@ ECONOMY_TEAM_NAME = "Economy"
# we have some large formsets sometimes # we have some large formsets sometimes
DATA_UPLOAD_MAX_NUMBER_FIELDS = 5000 DATA_UPLOAD_MAX_NUMBER_FIELDS = 5000
# use captcha form
ACCOUNT_SIGNUP_FORM_CLASS = "bornhack.forms.AllAuthSignupCaptchaForm"