inform user when an alias can't be created when a directory is disabled
This commit is contained in:
parent
37a74bc093
commit
ce3dae2a07
|
@ -8,6 +8,7 @@ from app.email_utils import (
|
||||||
send_cannot_create_directory_alias,
|
send_cannot_create_directory_alias,
|
||||||
send_cannot_create_domain_alias,
|
send_cannot_create_domain_alias,
|
||||||
can_create_directory_for_address,
|
can_create_directory_for_address,
|
||||||
|
send_cannot_create_directory_alias_disabled,
|
||||||
)
|
)
|
||||||
from app.errors import AliasInTrashError
|
from app.errors import AliasInTrashError
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
|
@ -66,6 +67,12 @@ def try_auto_create_directory(address: str) -> Optional[Alias]:
|
||||||
send_cannot_create_directory_alias(dir_user, address, directory_name)
|
send_cannot_create_directory_alias(dir_user, address, directory_name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if directory.disabled:
|
||||||
|
send_cannot_create_directory_alias_disabled(
|
||||||
|
dir_user, address, directory_name
|
||||||
|
)
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
LOG.d("create alias %s for directory %s", address, directory)
|
LOG.d("create alias %s for directory %s", address, directory)
|
||||||
|
|
||||||
|
|
|
@ -324,6 +324,9 @@ ALERT_MAILBOX_IS_ALIAS = "mailbox_is_alias"
|
||||||
|
|
||||||
AlERT_WRONG_MX_RECORD_CUSTOM_DOMAIN = "custom_domain_mx_record_issue"
|
AlERT_WRONG_MX_RECORD_CUSTOM_DOMAIN = "custom_domain_mx_record_issue"
|
||||||
|
|
||||||
|
# alert when a new alias is about to be created on a disabled directory
|
||||||
|
ALERT_DIRECTORY_DISABLED_ALIAS_CREATION = "alert_directory_disabled_alias_creation"
|
||||||
|
|
||||||
# <<<<< END ALERT EMAIL >>>>
|
# <<<<< END ALERT EMAIL >>>>
|
||||||
|
|
||||||
# Disable onboarding emails
|
# Disable onboarding emails
|
||||||
|
|
|
@ -37,6 +37,7 @@ from app.config import (
|
||||||
URL,
|
URL,
|
||||||
LANDING_PAGE_URL,
|
LANDING_PAGE_URL,
|
||||||
EMAIL_DOMAIN,
|
EMAIL_DOMAIN,
|
||||||
|
ALERT_DIRECTORY_DISABLED_ALIAS_CREATION,
|
||||||
)
|
)
|
||||||
from app.dns_utils import get_mx_domains
|
from app.dns_utils import get_mx_domains
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
|
@ -172,6 +173,28 @@ def send_cannot_create_directory_alias(user, alias_address, directory_name):
|
||||||
directory=directory_name,
|
directory=directory_name,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def send_cannot_create_directory_alias_disabled(user, alias_address, directory_name):
|
||||||
|
"""when the directory is disabled, new alias can't be created on-the-fly.
|
||||||
|
Send user an email to notify of an attempt
|
||||||
|
"""
|
||||||
|
send_email_with_rate_control(
|
||||||
|
user,
|
||||||
|
ALERT_DIRECTORY_DISABLED_ALIAS_CREATION,
|
||||||
|
user.email,
|
||||||
|
f"Alias {alias_address} cannot be created",
|
||||||
|
render(
|
||||||
|
"transactional/cannot-create-alias-directory-disabled.txt",
|
||||||
|
name=user.name,
|
||||||
|
alias=alias_address,
|
||||||
|
directory=directory_name,
|
||||||
|
),
|
||||||
|
render(
|
||||||
|
"transactional/cannot-create-alias-directory-disabled.html",
|
||||||
|
name=user.name,
|
||||||
|
alias=alias_address,
|
||||||
|
directory=directory_name,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{{ render_text("Hi " + name) }}
|
||||||
|
|
||||||
|
{% call text() %}
|
||||||
|
An email has been sent to the alias <b>{{ alias }}</b> that would be created automatically as you own the directory <b>{{ directory }}</b>
|
||||||
|
{% endcall %}
|
||||||
|
|
||||||
|
{% call text() %}
|
||||||
|
As <b>on-the-fly alias creation is disabled</b> on this directory, the alias isn't created.
|
||||||
|
{% endcall %}
|
||||||
|
|
||||||
|
{% call text() %}
|
||||||
|
If you aren't aware of this alias, that probably means someone has discovered about your directory and is abusing it.
|
||||||
|
{% endcall %}
|
||||||
|
|
||||||
|
|
||||||
|
{{ render_text('Thanks, <br />SimpleLogin Team.') }}
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,10 @@
|
||||||
|
Hi {{name}}
|
||||||
|
|
||||||
|
An email has been sent to the alias {{alias}} that would be created automatically as you own the directory {{directory}}.
|
||||||
|
|
||||||
|
As the directory has the on-the-fly alias creation disabled, the alias isn't created.
|
||||||
|
|
||||||
|
If you aren't aware of this alias, that probably means someone has discovered about your directory and is abusing it.
|
||||||
|
|
||||||
|
Best,
|
||||||
|
SimpleLogin team.
|
Loading…
Reference in New Issue