1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-08-21 18:07:20 +02:00

There was an error when an email was already used

This commit is contained in:
Yohann D'ANELLO
2020-12-04 01:25:17 +01:00
parent c658a9767d
commit de7f51d8da
2 changed files with 23 additions and 0 deletions

View File

@@ -22,6 +22,15 @@ class SignupForm(UserCreationForm):
],
)
def clean_email(self):
"""
Ensure that the email address is unique.
"""
email = self.data["email"]
if User.objects.filter(email=email).exists():
self.add_error("email", _("This email address is already used."))
return email
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["first_name"].required = True