Prevent invite requests from blocked domains

Prevents form submission when requesting an email invite using an address from a blocked domain.

Fixes #3366
This commit is contained in:
Hugh Rundle 2024-11-30 15:54:37 +11:00
parent 13381b9b4d
commit 023e62294e
No known key found for this signature in database
GPG key ID: A7E35779918253F9

View file

@ -64,6 +64,10 @@ class InviteRequestForm(CustomForm):
if email and models.User.objects.filter(email=email).exists(): if email and models.User.objects.filter(email=email).exists():
self.add_error("email", _("A user with this email already exists.")) self.add_error("email", _("A user with this email already exists."))
email_domain = email.split("@")[-1]
if email and models.EmailBlocklist.objects.filter(domain=email_domain).exists():
self.add_error("email", _("This email address cannot be registered."))
class Meta: class Meta:
model = models.InviteRequest model = models.InviteRequest
fields = ["email", "answer"] fields = ["email", "answer"]