mirror of
https://github.com/simple-login/app.git
synced 2024-11-16 00:48:32 +01:00
replace available_suffixes by available_suffixes_more_info
This commit is contained in:
parent
7915a2abb9
commit
5a3b79b4cf
4 changed files with 24 additions and 24 deletions
|
@ -3,7 +3,9 @@ from sqlalchemy import desc
|
|||
|
||||
from app.api.base import api_bp, require_api_auth
|
||||
from app.config import ALIAS_DOMAINS, DISABLE_ALIAS_SUFFIX
|
||||
from app.dashboard.views.custom_alias import available_suffixes
|
||||
from app.dashboard.views.custom_alias import (
|
||||
available_suffixes_more_info,
|
||||
)
|
||||
from app.extensions import db
|
||||
from app.log import LOG
|
||||
from app.models import AliasUsedOn, Alias, User
|
||||
|
@ -299,11 +301,10 @@ def options_v4():
|
|||
domain_name = convert_to_id(domain_name)
|
||||
ret["prefix_suggestion"] = domain_name
|
||||
|
||||
# List of (is_custom_domain, alias-suffix, time-signed alias-suffix)
|
||||
suffixes = available_suffixes(user)
|
||||
suffixes = available_suffixes_more_info(user)
|
||||
|
||||
# custom domain should be put first
|
||||
ret["suffixes"] = list([suffix[1], suffix[2]] for suffix in suffixes)
|
||||
ret["suffixes"] = list([suffix.suffix, suffix.signed_suffix] for suffix in suffixes)
|
||||
|
||||
return jsonify(ret)
|
||||
|
||||
|
@ -371,12 +372,12 @@ def options_v5():
|
|||
domain_name = convert_to_id(domain_name)
|
||||
ret["prefix_suggestion"] = domain_name
|
||||
|
||||
# List of (is_custom_domain, alias-suffix, time-signed alias-suffix)
|
||||
suffixes = available_suffixes(user)
|
||||
suffixes = available_suffixes_more_info(user)
|
||||
|
||||
# custom domain should be put first
|
||||
ret["suffixes"] = [
|
||||
{"suffix": suffix[1], "signed_suffix": suffix[2]} for suffix in suffixes
|
||||
{"suffix": suffix.suffix, "signed_suffix": suffix.signed_suffix}
|
||||
for suffix in suffixes
|
||||
]
|
||||
|
||||
return jsonify(ret)
|
||||
|
|
|
@ -109,11 +109,11 @@
|
|||
style="padding-left: 5px">
|
||||
<select class="form-control" name="suffix">
|
||||
{% for suffix in suffixes %}
|
||||
<option value="{{ suffix[2] }}">
|
||||
{% if suffix[0] %}
|
||||
{{ suffix[1] }} (your domain)
|
||||
<option value="{{ suffix.signed_suffix }}">
|
||||
{% if suffix.is_custom %}
|
||||
{{ suffix.suffix }} (your domain)
|
||||
{% else %}
|
||||
{{ suffix[1] }}
|
||||
{{ suffix.suffix }}
|
||||
{% endif %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
|
|
|
@ -7,7 +7,7 @@ from itsdangerous import SignatureExpired
|
|||
|
||||
from app.alias_utils import check_alias_prefix
|
||||
from app.config import EMAIL_DOMAIN
|
||||
from app.dashboard.views.custom_alias import available_suffixes, signer
|
||||
from app.dashboard.views.custom_alias import signer, available_suffixes_more_info
|
||||
from app.extensions import db
|
||||
from app.jose_utils import make_id_token
|
||||
from app.log import LOG
|
||||
|
@ -112,8 +112,7 @@ def authorize():
|
|||
user_custom_domains = [
|
||||
cd.domain for cd in current_user.verified_custom_domains()
|
||||
]
|
||||
# List of (is_custom_domain, alias-suffix, time-signed alias-suffix)
|
||||
suffixes = available_suffixes(current_user)
|
||||
suffixes = available_suffixes_more_info(current_user)
|
||||
|
||||
return render_template(
|
||||
"oauth/authorize.html",
|
||||
|
|
|
@ -5,7 +5,7 @@ from app.config import EMAIL_DOMAIN
|
|||
from app.dashboard.views.custom_alias import (
|
||||
signer,
|
||||
verify_prefix_suffix,
|
||||
available_suffixes,
|
||||
available_suffixes_more_info,
|
||||
)
|
||||
from app.extensions import db
|
||||
from app.models import (
|
||||
|
@ -108,13 +108,13 @@ def test_available_suffixes(flask_client):
|
|||
|
||||
CustomDomain.create(user_id=user.id, domain="test.com", verified=True)
|
||||
|
||||
assert len(available_suffixes(user)) > 0
|
||||
assert len(available_suffixes_more_info(user)) > 0
|
||||
|
||||
# first suffix is custom domain
|
||||
first_suffix = available_suffixes(user)[0]
|
||||
assert first_suffix[0]
|
||||
assert first_suffix[1] == "@test.com"
|
||||
assert first_suffix[2].startswith("@test.com")
|
||||
first_suffix = available_suffixes_more_info(user)[0]
|
||||
assert first_suffix.is_custom
|
||||
assert first_suffix.suffix == "@test.com"
|
||||
assert first_suffix.signed_suffix.startswith("@test.com")
|
||||
|
||||
|
||||
def test_available_suffixes_default_domain(flask_client):
|
||||
|
@ -126,13 +126,13 @@ def test_available_suffixes_default_domain(flask_client):
|
|||
user.default_alias_public_domain_id = sl_domain.id
|
||||
|
||||
# first suffix is SL Domain
|
||||
first_suffix = available_suffixes(user)[0]
|
||||
assert first_suffix[1].endswith(f"@{sl_domain.domain}")
|
||||
first_suffix = available_suffixes_more_info(user)[0]
|
||||
assert first_suffix.suffix.endswith(f"@{sl_domain.domain}")
|
||||
|
||||
user.default_alias_public_domain_id = None
|
||||
# first suffix is custom domain
|
||||
first_suffix = available_suffixes(user)[0]
|
||||
assert first_suffix[1] == "@test.com"
|
||||
first_suffix = available_suffixes_more_info(user)[0]
|
||||
assert first_suffix.suffix == "@test.com"
|
||||
|
||||
|
||||
def test_add_already_existed_alias(flask_client):
|
||||
|
|
Loading…
Reference in a new issue