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

This commit is contained in:
Pēteris Caune 2018-06-14 16:29:15 +03:00
parent 3241ea8c00
commit a4855e1900
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
4 changed files with 9 additions and 10 deletions

View File

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

View File

@ -17,7 +17,7 @@ class LoginTestCase(TestCase):
session["welcome_code"] = str(check.code)
session.save()
form = {"email": "alice@example.org"}
form = {"identity": "alice@example.org"}
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": "alice@example.org"}
form = {"identity": "alice@example.org"}
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": "dan@example.org"}
form = {"identity": "dan@example.org"}
r = self.client.post("/accounts/login/", form)
assert r.status_code == 200
@ -72,7 +72,7 @@ class LoginTestCase(TestCase):
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

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)

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="you@example.org">
</div>
</div>