Browse Source

Rename form field "email" to "identity" to hopefully avoid some auto-form-fill spam.

pull/178/head
Pēteris Caune 7 years ago
parent
commit
a4855e1900
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
4 changed files with 9 additions and 10 deletions
  1. +1
    -1
      hc/accounts/forms.py
  2. +4
    -4
      hc/accounts/tests/test_login.py
  3. +1
    -1
      hc/accounts/views.py
  4. +3
    -4
      templates/accounts/login.html

+ 1
- 1
hc/accounts/forms.py View File

@ -11,7 +11,7 @@ class LowercaseEmailField(forms.EmailField):
class EmailPasswordForm(forms.Form):
email = LowercaseEmailField()
identity = LowercaseEmailField()
password = forms.CharField(required=False)


+ 4
- 4
hc/accounts/tests/test_login.py View File

@ -17,7 +17,7 @@ class LoginTestCase(TestCase):
session["welcome_code"] = str(check.code)
session.save()
form = {"email": "[email protected]"}
form = {"identity": "[email protected]"}
r = self.client.post("/accounts/login/", form)
assert r.status_code == 302
@ -47,7 +47,7 @@ class LoginTestCase(TestCase):
session["welcome_code"] = "00000000-0000-0000-0000-000000000000"
session.save()
form = {"email": "[email protected]"}
form = {"identity": "[email protected]"}
r = self.client.post("/accounts/login/", form)
assert r.status_code == 302
@ -62,7 +62,7 @@ class LoginTestCase(TestCase):
@override_settings(REGISTRATION_OPEN=False)
def test_it_obeys_registration_open(self):
form = {"email": "[email protected]"}
form = {"identity": "[email protected]"}
r = self.client.post("/accounts/login/", form)
assert r.status_code == 200
@ -72,7 +72,7 @@ class LoginTestCase(TestCase):
alice = User(username="alice", email="[email protected]")
alice.save()
form = {"email": "[email protected]"}
form = {"identity": "[email protected]"}
r = self.client.post("/accounts/login/", form)
assert r.status_code == 302


+ 1
- 1
hc/accounts/views.py View File

@ -78,7 +78,7 @@ def login(request, show_password=False):
if request.method == 'POST':
form = EmailPasswordForm(request.POST)
if form.is_valid():
email = form.cleaned_data["email"]
email = form.cleaned_data["identity"]
password = form.cleaned_data["password"]
if len(password):
user = authenticate(username=email, password=password)


+ 3
- 4
templates/accounts/login.html View File

@ -40,10 +40,9 @@
<input
type="text"
class="form-control"
id="id_email"
name="email"
value="{{ form.email.value|default:"" }}"
placeholder="Email">
name="identity"
value="{{ form.identity.value|default:"" }}"
placeholder="[email protected]">
</div>
</div>


Loading…
Cancel
Save