Check trusted email domains
This commit is contained in:
parent
0391639bed
commit
1853ca96bb
1 changed files with 15 additions and 1 deletions
|
|
@ -9,9 +9,23 @@ class RegistrationForm(UserCreationForm):
|
||||||
label=_("Email address"),
|
label=_("Email address"),
|
||||||
widget=forms.TextInput(),
|
widget=forms.TextInput(),
|
||||||
required=True,
|
required=True,
|
||||||
help_text=_("Please enter a valid email address ending with `@crans.org` or `@ens-paris-saclay.fr`."),
|
help_text=_(
|
||||||
|
"Please enter a valid email address ending with `@crans.org` or "
|
||||||
|
"`@ens-paris-saclay.fr`."
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def clean_email(self):
|
||||||
|
"""
|
||||||
|
Check that the email address ends with a trusted domain.
|
||||||
|
"""
|
||||||
|
email = self.cleaned_data.get("email")
|
||||||
|
if not email.endswith("@crans.org") and not email.endswith("@ens-paris-saclay.fr"):
|
||||||
|
raise forms.ValidationError(
|
||||||
|
_("Must end with `@crans.org` or `@ens-paris-saclay.fr`.")
|
||||||
|
)
|
||||||
|
return email
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ["username", "password1", "password2", "email"]
|
fields = ["username", "password1", "password2", "email"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue