From 023e62294e0371d79e343ecd1fbc059ff84f654e Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 30 Nov 2024 15:54:37 +1100 Subject: [PATCH] Prevent invite requests from blocked domains Prevents form submission when requesting an email invite using an address from a blocked domain. Fixes #3366 --- bookwyrm/forms/landing.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bookwyrm/forms/landing.py b/bookwyrm/forms/landing.py index 831d1d539..4f5b3223f 100644 --- a/bookwyrm/forms/landing.py +++ b/bookwyrm/forms/landing.py @@ -64,6 +64,10 @@ class InviteRequestForm(CustomForm): if email and models.User.objects.filter(email=email).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: model = models.InviteRequest fields = ["email", "answer"]