forked from GithubBackups/healthchecks
Handle excessively long email addresses in the signup form.
This commit is contained in:
parent
8223b0c402
commit
ffafc16fe5
@ -7,6 +7,9 @@ All notable changes to this project will be documented in this file.
|
||||
- Django 3.1
|
||||
- Handle status callbacks from Twilio, show delivery failures in Integrations
|
||||
|
||||
## Bug Fixes
|
||||
- Handle excessively long email addresses in the signup form.
|
||||
|
||||
## v1.16.0 - 2020-08-04
|
||||
|
||||
### Improvements
|
||||
|
@ -20,6 +20,9 @@ class AvailableEmailForm(forms.Form):
|
||||
|
||||
def clean_identity(self):
|
||||
v = self.cleaned_data["identity"]
|
||||
if len(v) > 254:
|
||||
raise forms.ValidationError("Address is too long.")
|
||||
|
||||
if User.objects.filter(email=v).exists():
|
||||
raise forms.ValidationError(
|
||||
"An account with this email address already exists."
|
||||
|
@ -81,3 +81,11 @@ class SignupTestCase(TestCase):
|
||||
form = {"identity": "alice at example org"}
|
||||
r = self.client.post("/accounts/signup/", form)
|
||||
self.assertContains(r, "Enter a valid email address")
|
||||
|
||||
def test_it_checks_length(self):
|
||||
aaa = "a" * 300
|
||||
form = {"identity": f"alice+{aaa}@example.org"}
|
||||
r = self.client.post("/accounts/signup/", form)
|
||||
self.assertContains(r, "Address is too long.")
|
||||
|
||||
self.assertFalse(User.objects.exists())
|
||||
|
Loading…
x
Reference in New Issue
Block a user