mirror of
https://github.com/simple-login/app.git
synced 2024-11-13 07:31:12 +01:00
Fix: If the default domain is hidden do not return it (#1761)
Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
parent
ff33392398
commit
9d9e5fcab6
2 changed files with 25 additions and 1 deletions
|
@ -170,7 +170,7 @@ def get_alias_suffixes(
|
|||
|
||||
if not default_domain_found:
|
||||
sl_domain = SLDomain.get(user.default_alias_public_domain_id)
|
||||
if sl_domain:
|
||||
if sl_domain and not sl_domain.hidden:
|
||||
prefix = (
|
||||
""
|
||||
if config.DISABLE_ALIAS_SUFFIX
|
||||
|
|
|
@ -60,6 +60,30 @@ def test_get_default_domain_even_if_is_not_allowed():
|
|||
assert suffixes[0].domain == default_domain.domain
|
||||
|
||||
|
||||
def test_get_default_domain_hidden():
|
||||
user = create_new_user()
|
||||
PartnerUser.create(
|
||||
partner_id=get_proton_partner().id,
|
||||
user_id=user.id,
|
||||
external_user_id=random_token(10),
|
||||
flush=True,
|
||||
)
|
||||
user.trial_end = None
|
||||
default_domain = SLDomain.filter_by(
|
||||
hidden=True, partner_id=None, premium_only=False
|
||||
).first()
|
||||
user.default_alias_public_domain_id = default_domain.id
|
||||
Session.flush()
|
||||
options = AliasOptions(
|
||||
show_sl_domains=False, show_partner_domains=get_proton_partner()
|
||||
)
|
||||
suffixes = get_alias_suffixes(user, alias_options=options)
|
||||
for suffix in suffixes:
|
||||
domain = SLDomain.get_by(domain=suffix.domain)
|
||||
assert not domain.hidden
|
||||
assert suffixes[0].domain != default_domain.domain
|
||||
|
||||
|
||||
def test_suffixes_are_valid():
|
||||
user = create_new_user()
|
||||
PartnerUser.create(
|
||||
|
|
Loading…
Reference in a new issue