Skip to content

Commit

Permalink
fix(account): Ignore casing differences in email2
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed May 30, 2024
1 parent 44d957b commit 11a5964
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion allauth/account/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def clean(self):
if app_settings.SIGNUP_EMAIL_ENTER_TWICE:
email = cleaned_data.get("email")
email2 = cleaned_data.get("email2")
if (email and email2) and email != email2:
if (email and email2) and email != email2.lower():

This comment has been minimized.

Copy link
@davefrassoni

davefrassoni May 30, 2024

@pennersr mybe a cleaner way is to make the .lower() in a new method: def clean_email2()
at file: allauth/account/forms.py
just like you made with def clean_email()

This comment has been minimized.

Copy link
@pennersr

pennersr May 31, 2024

Author Owner

You're right -- c5d4d54

self.add_error("email2", _("You must type the same email each time."))
return cleaned_data

Expand Down
40 changes: 20 additions & 20 deletions allauth/account/tests/test_signup.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,28 +112,28 @@ def test_username_maxlength(self):
widget = field.widget
self.assertEqual(widget.attrs.get("maxlength"), str(max_length))

@override_settings(
ACCOUNT_USERNAME_REQUIRED=True, ACCOUNT_SIGNUP_EMAIL_ENTER_TWICE=True
)
def test_signup_email_verification(self):
data = {
"username": "username",
"email": "user@example.com",
}
form = BaseSignupForm(data, email_required=True)
self.assertFalse(form.is_valid())

data = {
"username": "username",
"email": "user@example.com",
"email2": "user@example.com",
}
form = BaseSignupForm(data, email_required=True)
self.assertTrue(form.is_valid())
def test_signup_email_verification(settings, db):
settings.ACCOUNT_USERNAME_REQUIRED = True
settings.ACCOUNT_SIGNUP_EMAIL_ENTER_TWICE = True
data = {
"username": "username",
"email": "user@example.com",
}
form = BaseSignupForm(data, email_required=True)
assert not form.is_valid()

data["email2"] = "anotheruser@example.com"
form = BaseSignupForm(data, email_required=True)
self.assertFalse(form.is_valid())
data = {
"username": "username",
"email": "user@example.com",
"email2": "USER@example.COM",
}
form = BaseSignupForm(data, email_required=True)
assert form.is_valid()

data["email2"] = "anotheruser@example.com"
form = BaseSignupForm(data, email_required=True)
assert not form.is_valid()


@override_settings(
Expand Down

0 comments on commit 11a5964

Please sign in to comment.