Skip to content

Commit

Permalink
Fix: Allow to create mailboxes for a custom domain if they are not sl…
Browse files Browse the repository at this point in the history
… domains (#2236)
  • Loading branch information
acasajus authored Oct 2, 2024
1 parent b97a1dd commit 06ab116
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/email_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def email_can_be_used_as_mailbox(email_address: str) -> bool:

from app.models import CustomDomain

if CustomDomain.get_by(domain=domain, verified=True):
if CustomDomain.get_by(domain=domain, is_sl_subdomain=True, verified=True):
LOG.d("domain %s is a SimpleLogin custom domain", domain)
return False

Expand Down
11 changes: 9 additions & 2 deletions tests/test_email_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,19 @@ def test_can_be_used_as_personal_email(flask_client):
assert not email_can_be_used_as_mailbox("[email protected]")
assert not email_can_be_used_as_mailbox("[email protected]")

# custom domain
# custom domain as SL domain
domain = random_domain()
user = create_new_user()
CustomDomain.create(user_id=user.id, domain=domain, verified=True, commit=True)
domain_obj = CustomDomain.create(
user_id=user.id, domain=domain, verified=True, is_sl_subdomain=True, flush=True
)
assert not email_can_be_used_as_mailbox(f"hey@{domain}")

# custom domain is NOT SL domain
domain_obj.is_sl_subdomain = False
Session.flush()
assert email_can_be_used_as_mailbox(f"hey@{domain}")

# disposable domain
disposable_domain = random_domain()
InvalidMailboxDomain.create(domain=disposable_domain, commit=True)
Expand Down

0 comments on commit 06ab116

Please sign in to comment.