fix the case public domain is also a custom domain for a specific user: check for public domain first.
This commit is contained in:
parent
f5e6f541ff
commit
1bbc416ec1
|
@ -162,31 +162,37 @@ def setting():
|
||||||
|
|
||||||
elif request.form.get("form-name") == "change-random-alias-default-domain":
|
elif request.form.get("form-name") == "change-random-alias-default-domain":
|
||||||
default_domain = request.form.get("random-alias-default-domain")
|
default_domain = request.form.get("random-alias-default-domain")
|
||||||
|
|
||||||
if default_domain:
|
if default_domain:
|
||||||
custom_domain = CustomDomain.get_by(domain=default_domain)
|
public_domain = PublicDomain.get_by(domain=default_domain)
|
||||||
if custom_domain:
|
if public_domain:
|
||||||
# sanity check
|
# make sure only default_random_alias_domain_id or default_random_alias_public_domain_id is set
|
||||||
if (
|
current_user.default_random_alias_public_domain_id = (
|
||||||
custom_domain.user_id != current_user.id
|
public_domain.id
|
||||||
or not custom_domain.verified
|
)
|
||||||
):
|
current_user.default_random_alias_domain_id = None
|
||||||
LOG.error(
|
|
||||||
"%s cannot use domain %s", current_user, default_domain
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
# make sure only default_random_alias_domain_id or default_random_alias_public_domain_id is set
|
|
||||||
current_user.default_random_alias_domain_id = custom_domain.id
|
|
||||||
current_user.default_random_alias_public_domain_id = None
|
|
||||||
else:
|
else:
|
||||||
public_domain = PublicDomain.get_by(domain=default_domain)
|
custom_domain = CustomDomain.get_by(domain=default_domain)
|
||||||
if public_domain:
|
if custom_domain:
|
||||||
# make sure only default_random_alias_domain_id or default_random_alias_public_domain_id is set
|
# sanity check
|
||||||
current_user.default_random_alias_public_domain_id = (
|
if (
|
||||||
public_domain.id
|
custom_domain.user_id != current_user.id
|
||||||
)
|
or not custom_domain.verified
|
||||||
current_user.default_random_alias_domain_id = None
|
):
|
||||||
|
LOG.error(
|
||||||
|
"%s cannot use domain %s", current_user, default_domain
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# make sure only default_random_alias_domain_id or
|
||||||
|
# default_random_alias_public_domain_id is set
|
||||||
|
current_user.default_random_alias_domain_id = (
|
||||||
|
custom_domain.id
|
||||||
|
)
|
||||||
|
current_user.default_random_alias_public_domain_id = None
|
||||||
|
|
||||||
else:
|
else:
|
||||||
current_user.default_random_alias_domain_id = None
|
current_user.default_random_alias_domain_id = None
|
||||||
|
current_user.default_random_alias_public_domain_id = None
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash("Your preference has been updated", "success")
|
flash("Your preference has been updated", "success")
|
||||||
|
|
Loading…
Reference in a new issue