diff --git a/hc/accounts/forms.py b/hc/accounts/forms.py index a1765fa2..ab389830 100644 --- a/hc/accounts/forms.py +++ b/hc/accounts/forms.py @@ -13,10 +13,12 @@ class LowercaseEmailField(forms.EmailField): class EmailForm(forms.Form): - email = LowercaseEmailField() + # Call it "identity" instead of "email" + # to avoid some of the dumber bots + identity = LowercaseEmailField() - def clean_email(self): - v = self.cleaned_data["email"] + def clean_identity(self): + v = self.cleaned_data["identity"] # If registration is not open then validate if an user # account with this address exists- diff --git a/hc/accounts/tests/test_login.py b/hc/accounts/tests/test_login.py index a2a7b088..0d640dbe 100644 --- a/hc/accounts/tests/test_login.py +++ b/hc/accounts/tests/test_login.py @@ -10,7 +10,7 @@ from django.conf import settings class LoginTestCase(TestCase): def test_it_sends_link(self): - form = {"email": "alice@example.org"} + form = {"identity": "alice@example.org"} r = self.client.post("/accounts/login/", form) assert r.status_code == 302 @@ -34,17 +34,17 @@ class LoginTestCase(TestCase): @override_settings(REGISTRATION_OPEN=False) def test_it_obeys_registration_open(self): - form = {"email": "dan@example.org"} + form = {"identity": "dan@example.org"} r = self.client.post("/accounts/login/", form) assert r.status_code == 200 self.assertContains(r, "Incorrect email") - def test_it_ignores_ces(self): + def test_it_ignores_case(self): alice = User(username="alice", email="alice@example.org") alice.save() - form = {"email": "ALICE@EXAMPLE.ORG"} + form = {"identity": "ALICE@EXAMPLE.ORG"} r = self.client.post("/accounts/login/", form) assert r.status_code == 302 diff --git a/hc/accounts/views.py b/hc/accounts/views.py index a88d5722..e85cd9a4 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -71,7 +71,7 @@ def login(request): else: magic_form = EmailForm(request.POST) if magic_form.is_valid(): - email = magic_form.cleaned_data["email"] + email = magic_form.cleaned_data["identity"] user = None try: user = User.objects.get(email=email) diff --git a/templates/accounts/login.html b/templates/accounts/login.html index 474919f6..edc3a766 100644 --- a/templates/accounts/login.html +++ b/templates/accounts/login.html @@ -18,16 +18,16 @@