email disposable domains
This commit is contained in:
@@ -1000,6 +1000,8 @@ class RegistrationFormTermsOfService(RegistrationForm):
|
||||
error_messages={'required': "You must agree to the terms to register"})
|
||||
|
||||
|
||||
DISPOSABLE_DOMAINS = ["powerscrews.com"]
|
||||
|
||||
class RegistrationFormUniqueEmail(RegistrationFormTermsOfService):
|
||||
"""
|
||||
Subclass of ``RegistrationFormTermsOfService`` which enforces uniqueness of
|
||||
@@ -1011,6 +1013,12 @@ class RegistrationFormUniqueEmail(RegistrationFormTermsOfService):
|
||||
Validate that the supplied email address is unique for the
|
||||
site.
|
||||
"""
|
||||
|
||||
email = self.cleaned_data['email']
|
||||
domain = email.split('@')[-1].lower()
|
||||
if domain in DISPOSABLE_DOMAINS:
|
||||
raise ValidationError("Registration using this domain is not allowed")
|
||||
|
||||
if User.objects.filter(email__iexact=self.cleaned_data['email']): # pragma: no cover
|
||||
raise forms.ValidationError(
|
||||
"This email address is already in use. Please supply a different email address.")
|
||||
|
||||
Reference in New Issue
Block a user