mirror of
https://github.com/simple-login/app.git
synced 2024-09-20 15:05:59 +08:00
user can create aliases for domains that don't have mx verified
This commit is contained in:
parent
bd614278df
commit
83be94b43e
|
@ -47,9 +47,6 @@ class SuffixInfo:
|
|||
|
||||
def get_available_suffixes(user: User) -> [SuffixInfo]:
|
||||
"""
|
||||
Similar to as available_suffixes() but also return whether the suffix comes from a premium domain
|
||||
Note that is-premium-domain is only relevant for SL domain
|
||||
|
||||
WARNING: should use get_alias_suffixes() instead
|
||||
"""
|
||||
user_custom_domains = user.verified_custom_domains()
|
||||
|
@ -111,6 +108,9 @@ class AliasSuffix:
|
|||
# can be either Custom or SL domain
|
||||
domain: str
|
||||
|
||||
# if custom domain, whether the custom domain has MX verified, i.e. can receive emails
|
||||
mx_verified: bool
|
||||
|
||||
def serialize(self):
|
||||
return json.dumps(asdict(self))
|
||||
|
||||
|
@ -121,10 +121,11 @@ class AliasSuffix:
|
|||
|
||||
def get_alias_suffixes(user: User) -> [AliasSuffix]:
|
||||
"""
|
||||
Similar to as available_suffixes() but also return whether the suffix comes from a premium domain
|
||||
Note that is-premium-domain is only relevant for SL domain
|
||||
Similar to as get_available_suffixes() but also return custom domain that doesn't have MX set up.
|
||||
"""
|
||||
user_custom_domains = user.verified_custom_domains()
|
||||
user_custom_domains = CustomDomain.filter_by(
|
||||
user_id=user.id, ownership_verified=True
|
||||
).all()
|
||||
|
||||
alias_suffixes: [AliasSuffix] = []
|
||||
|
||||
|
@ -138,6 +139,7 @@ def get_alias_suffixes(user: User) -> [AliasSuffix]:
|
|||
suffix=suffix,
|
||||
is_premium=False,
|
||||
domain=custom_domain.domain,
|
||||
mx_verified=custom_domain.verified,
|
||||
)
|
||||
if user.default_alias_custom_domain_id == custom_domain.id:
|
||||
alias_suffixes.insert(0, alias_suffix)
|
||||
|
@ -146,7 +148,11 @@ def get_alias_suffixes(user: User) -> [AliasSuffix]:
|
|||
|
||||
suffix = "@" + custom_domain.domain
|
||||
alias_suffix = AliasSuffix(
|
||||
is_custom=True, suffix=suffix, is_premium=False, domain=custom_domain.domain
|
||||
is_custom=True,
|
||||
suffix=suffix,
|
||||
is_premium=False,
|
||||
domain=custom_domain.domain,
|
||||
mx_verified=custom_domain.verified,
|
||||
)
|
||||
|
||||
# put the default domain to top
|
||||
|
@ -171,6 +177,7 @@ def get_alias_suffixes(user: User) -> [AliasSuffix]:
|
|||
suffix=suffix,
|
||||
is_premium=sl_domain.premium_only,
|
||||
domain=sl_domain.domain,
|
||||
mx_verified=True,
|
||||
)
|
||||
|
||||
# put the default domain to top
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
This part is to avoid a person taking all the "nice" aliases like
|
||||
<b>hello@{{ FIRST_ALIAS_DOMAIN }}</b>,
|
||||
<b>me@{{ FIRST_ALIAS_DOMAIN }}</b>, etc. <br>
|
||||
If you add your own domain, this restriction is removed and you can fully customize the alias. <br>
|
||||
If you add your own domain, this restriction is removed, and you can fully customize the alias. <br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -47,13 +47,17 @@
|
|||
{% set alias_suffix = suffix_info[0] %}
|
||||
<option value="{{ suffix_info[1] }}"
|
||||
{% if alias_suffix.is_premium %}
|
||||
title="Only available to Premium accounts"
|
||||
title="Only available to Premium accounts"
|
||||
{% elif not alias_suffix.is_custom and at_least_a_premium_domain %}
|
||||
title="Available to all accounts"
|
||||
title="Available to all accounts"
|
||||
{% endif %}
|
||||
>
|
||||
{% if alias_suffix.is_custom %}
|
||||
{{ alias_suffix.suffix }} (your domain)
|
||||
{% if alias_suffix.mx_verified %}
|
||||
{{ alias_suffix.suffix }} (your domain)
|
||||
{% else %}
|
||||
{{ alias_suffix.suffix }} (your domain, not MX verified yet)
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if alias_suffix.is_premium %}
|
||||
{{ alias_suffix.suffix }} (Premium domain)
|
||||
|
@ -107,9 +111,9 @@
|
|||
{% block script %}
|
||||
<script>
|
||||
$('.mailbox-select').multipleSelect();
|
||||
|
||||
|
||||
// Ctrl-enter submit the form
|
||||
$('form').keydown(function(event) {
|
||||
$('form').keydown(function (event) {
|
||||
if (event.ctrlKey && event.keyCode === 13) {
|
||||
$("#submit").click();
|
||||
}
|
||||
|
|
|
@ -273,6 +273,11 @@
|
|||
title="This alias was found in {{ alias.hibp_breaches | length }} data breaches. Check haveibeenpwned.com for more information."></span>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% if alias_info.custom_domain and not alias_info.custom_domain.verified %}
|
||||
<span class="fa fa-warning text-warning" data-toggle="tooltip"
|
||||
title="Alias can't receive emails as its domain doesn't have MX records set up."></span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col text-right">
|
||||
<label class="custom-switch cursor"
|
||||
|
|
Loading…
Reference in a new issue