Example #1
0
    def clean_email(self):
        # Since User.username is unique, this check is redundant,
        # but it sets a nicer error message than the ORM. See #13147.
        email = self.cleaned_data["email"]

        email_checker = DisposableEmailChecker()
        if email_checker.is_disposable(email):
            raise forms.ValidationError(_("Registration using disposable email addresses is prohibited. \
            Please supply a different email address."))
        return email
Example #2
0
 def clean_email(self):
     email_checker = DisposableEmailChecker()
     if User.objects.filter(email=self.cleaned_data['email']).exists():
         raise forms.ValidationError(
             "the given email is already registered")
     else:
         if email_checker.is_disposable(email=self.cleaned_data['email']):
             raise forms.ValidationError(
                 _('Please use a different email address provider.'))
     return self.cleaned_data['email']
Example #3
0
    def clean_email(self):
        email = self.data['email']

        if settings.DEBUG is False:
            email_checker = DisposableEmailChecker()
            if email_checker.is_disposable(email):
                raise forms.ValidationError(self.error_messages['bad_email_provider'])

        try:
            User.objects.get(email=email)
        except User.DoesNotExist:
            return email
        raise forms.ValidationError(self.error_messages['duplicate_email'])
Example #4
0
    def clean_email(self):
        # Since User.username is unique, this check is redundant,
        # but it sets a nicer error message than the ORM. See #13147.
        email = self.cleaned_data["email"]

        email_checker = DisposableEmailChecker()
        if email_checker.is_disposable(email):
            raise forms.ValidationError(_("Registration using disposable email addresses is prohibited. \
            Please supply a different email address."))

        try:
            User._default_manager.get(email=email)
        except User.DoesNotExist:
            return email
        raise forms.ValidationError(self.error_messages['duplicate_email'])
Example #5
0
 def is_disposable(self, email):
     """ Renvoyer si une adresse email est de type jetable """
     return self.is_invalid(
         email) or DisposableEmailChecker().is_disposable(email)