Skip to content

Commit

Permalink
Prevent invite requests from blocked domains
Browse files Browse the repository at this point in the history
Prevents form submission when requesting an email invite using an address from a blocked domain.

Fixes #3366
  • Loading branch information
hughrun committed Nov 30, 2024
1 parent 13381b9 commit 023e622
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bookwyrm/forms/landing.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def clean(self):
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"]
Expand Down

0 comments on commit 023e622

Please sign in to comment.