forked from Github-Mirrors/canaille
Renamed User.email in User.emails
This commit is contained in:
parent
14ec6e9c9e
commit
371f806695
32 changed files with 119 additions and 115 deletions
|
@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_,
|
||||
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.
|
||||
|
||||
🚨Configuration files must be updated.🚨
|
||||
Check the new format with ``git diff 0.0.27 0.0.26 canaille/conf/config.sample.toml``
|
||||
|
||||
Added
|
||||
*****
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ class Backend(BaseBackend):
|
|||
formatted_name=f"canaille_{uuid.uuid4()}",
|
||||
family_name=f"canaille_{uuid.uuid4()}",
|
||||
user_name=f"canaille_{uuid.uuid4()}",
|
||||
email=f"canaille_{uuid.uuid4()}@mydomain.tld",
|
||||
emails=f"canaille_{uuid.uuid4()}@mydomain.tld",
|
||||
password="correct horse battery staple",
|
||||
)
|
||||
user.save(conn)
|
||||
|
@ -186,7 +186,7 @@ class Backend(BaseBackend):
|
|||
cn=f"canaille_{uuid.uuid4()}",
|
||||
family_name=f"canaille_{uuid.uuid4()}",
|
||||
user_name=f"canaille_{uuid.uuid4()}",
|
||||
email=f"canaille_{uuid.uuid4()}@mydomain.tld",
|
||||
emails=f"canaille_{uuid.uuid4()}@mydomain.tld",
|
||||
password="correct horse battery staple",
|
||||
)
|
||||
user.save(conn)
|
||||
|
|
|
@ -24,7 +24,7 @@ class User(canaille.core.models.User, LDAPObject):
|
|||
"given_name": "givenName",
|
||||
"formatted_name": "cn",
|
||||
"display_name": "displayName",
|
||||
"email": "mail",
|
||||
"emails": "mail",
|
||||
"phone_number": "telephoneNumber",
|
||||
"formatted_address": "postalAddress",
|
||||
"street": "street",
|
||||
|
|
|
@ -138,7 +138,7 @@ WRITE = [
|
|||
"display_name",
|
||||
"password",
|
||||
"phone_number",
|
||||
"email",
|
||||
"emails",
|
||||
"profile_url",
|
||||
"formatted_address",
|
||||
"street",
|
||||
|
@ -204,7 +204,7 @@ PUBLIC_KEY = "canaille/conf/public.pem"
|
|||
# SUB = "{{ user.user_name[0] }}"
|
||||
# NAME = "{{ user.formatted_name[0] }}"
|
||||
# PHONE_NUMBER = "{{ user.phone_number[0] }}"
|
||||
# EMAIL = "{{ user.mail[0] }}"
|
||||
# EMAIL = "{{ user.emails[0] }}"
|
||||
# GIVEN_NAME = "{{ user.given_name[0] }}"
|
||||
# FAMILY_NAME = "{{ user.family_name[0] }}"
|
||||
# PREFERRED_USERNAME = "{{ user.display_name }}"
|
||||
|
|
|
@ -307,7 +307,7 @@ def registration(data, hash):
|
|||
|
||||
data = {
|
||||
"user_name": invitation.user_name,
|
||||
"email": invitation.email,
|
||||
"emails": invitation.email,
|
||||
"groups": invitation.groups,
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,7 @@ def profile_edition(user, username):
|
|||
"given_name",
|
||||
"family_name",
|
||||
"display_name",
|
||||
"email",
|
||||
"emails",
|
||||
"phone_number",
|
||||
"formatted_address",
|
||||
"street",
|
||||
|
@ -529,7 +529,7 @@ def profile_settings(user, username):
|
|||
if send_password_initialization_mail(edited_user):
|
||||
flash(
|
||||
_(
|
||||
"A password initialization link has been sent at the user email address. It should be received within a few minutes."
|
||||
"A password initialization link has been sent at the user.emails address. It should be received within a few minutes."
|
||||
),
|
||||
"success",
|
||||
)
|
||||
|
@ -542,7 +542,7 @@ def profile_settings(user, username):
|
|||
if send_password_reset_mail(edited_user):
|
||||
flash(
|
||||
_(
|
||||
"A password reset link has been sent at the user email address. It should be received within a few minutes."
|
||||
"A password reset link has been sent at the user.emails address. It should be received within a few minutes."
|
||||
),
|
||||
"success",
|
||||
)
|
||||
|
@ -721,7 +721,7 @@ def reset(user_name, hash):
|
|||
|
||||
if not user or hash != profile_hash(
|
||||
user.user_name[0],
|
||||
user.email[0],
|
||||
user.emails[0],
|
||||
user.password[0] if user.has_password() else "",
|
||||
):
|
||||
flash(
|
||||
|
|
|
@ -76,7 +76,7 @@ def password_init_html(user):
|
|||
reset_url = url_for(
|
||||
"account.reset",
|
||||
user_name=user.user_name[0],
|
||||
hash=profile_hash(user.user_name[0], user.email[0], user.password[0]),
|
||||
hash=profile_hash(user.user_name[0], user.emails[0], user.password[0]),
|
||||
_external=True,
|
||||
)
|
||||
|
||||
|
@ -99,7 +99,7 @@ def password_init_txt(user):
|
|||
reset_url = url_for(
|
||||
"account.reset",
|
||||
user_name=user.user_name[0],
|
||||
hash=profile_hash(user.user_name[0], user.email[0], user.password[0]),
|
||||
hash=profile_hash(user.user_name[0], user.emails[0], user.password[0]),
|
||||
_external=True,
|
||||
)
|
||||
|
||||
|
@ -118,7 +118,7 @@ def password_reset_html(user):
|
|||
reset_url = url_for(
|
||||
"account.reset",
|
||||
user_name=user.user_name[0],
|
||||
hash=profile_hash(user.user_name[0], user.email[0], user.password[0]),
|
||||
hash=profile_hash(user.user_name[0], user.emails[0], user.password[0]),
|
||||
_external=True,
|
||||
)
|
||||
|
||||
|
@ -141,7 +141,7 @@ def password_reset_txt(user):
|
|||
reset_url = url_for(
|
||||
"account.reset",
|
||||
user_name=user.user_name[0],
|
||||
hash=profile_hash(user.user_name[0], user.email[0], user.password[0]),
|
||||
hash=profile_hash(user.user_name[0], user.emails[0], user.password[0]),
|
||||
_external=True,
|
||||
)
|
||||
|
||||
|
|
|
@ -25,8 +25,9 @@ def unique_login(form, field):
|
|||
|
||||
|
||||
def unique_email(form, field):
|
||||
if models.User.get(email=field.data) and (
|
||||
not getattr(form, "user", None) or form.user.email[0] != field.data
|
||||
if models.User.get(emails=field.data) and (
|
||||
not getattr(form, "user", None)
|
||||
or any(email != field.data for email in form.user.emails)
|
||||
):
|
||||
raise wtforms.ValidationError(
|
||||
_("The email '{email}' is already used").format(email=field.data)
|
||||
|
@ -155,7 +156,7 @@ PROFILE_FORM_FIELDS = dict(
|
|||
"autocorrect": "off",
|
||||
},
|
||||
),
|
||||
email=wtforms.EmailField(
|
||||
emails=wtforms.EmailField(
|
||||
_("Email address"),
|
||||
validators=[
|
||||
wtforms.validators.DataRequired(),
|
||||
|
|
|
@ -42,7 +42,7 @@ def send_password_reset_mail(user):
|
|||
user_name=user.user_name[0],
|
||||
hash=profile_hash(
|
||||
user.user_name[0],
|
||||
user.email[0],
|
||||
user.emails[0],
|
||||
user.password[0] if user.has_password() else "",
|
||||
),
|
||||
_external=True,
|
||||
|
@ -68,7 +68,7 @@ def send_password_reset_mail(user):
|
|||
|
||||
return send_email(
|
||||
subject=subject,
|
||||
recipient=user.email[0],
|
||||
recipient=user.emails[0],
|
||||
text=text_body,
|
||||
html=html_body,
|
||||
attachements=[(logo_cid, logo_filename, logo_raw)] if logo_filename else None,
|
||||
|
@ -82,7 +82,7 @@ def send_password_initialization_mail(user):
|
|||
user_name=user.user_name[0],
|
||||
hash=profile_hash(
|
||||
user.user_name[0],
|
||||
user.email[0],
|
||||
user.emails[0],
|
||||
user.password[0] if user.has_password() else "",
|
||||
),
|
||||
_external=True,
|
||||
|
@ -108,7 +108,7 @@ def send_password_initialization_mail(user):
|
|||
|
||||
return send_email(
|
||||
subject=subject,
|
||||
recipient=user.email[0],
|
||||
recipient=user.emails[0],
|
||||
text=text_body,
|
||||
html=html_body,
|
||||
attachements=[(logo_cid, logo_filename, logo_raw)] if logo_filename else None,
|
||||
|
|
|
@ -23,7 +23,7 @@ def fake_users(nb=1):
|
|||
given_name=name.split(" ")[0],
|
||||
family_name=name.split(" ")[1],
|
||||
user_name=fake.unique.user_name(),
|
||||
email=fake.unique.email(),
|
||||
emails=fake.unique.email(),
|
||||
phone_number=fake.unique.ssn(),
|
||||
profile_url=fake.unique.uri(),
|
||||
address=fake.unique.address(),
|
||||
|
|
|
@ -39,7 +39,7 @@ DEFAULT_JWT_MAPPING = {
|
|||
"SUB": "{{ user.user_name[0] }}",
|
||||
"NAME": "{% if user.formatted_name %}{{ user.formatted_name[0] }}{% endif %}",
|
||||
"PHONE_NUMBER": "{% if user.phone_number %}{{ user.phone_number[0] }}{% endif %}",
|
||||
"EMAIL": "{% if user.email %}{{ user.email[0] }}{% endif %}",
|
||||
"EMAIL": "{% if user.emails %}{{ user.emails[0] }}{% endif %}",
|
||||
"GIVEN_NAME": "{% if user.given_name %}{{ user.given_name[0] }}{% endif %}",
|
||||
"FAMILY_NAME": "{% if user.family_name %}{{ user.family_name[0] }}{% endif %}",
|
||||
"PREFERRED_USERNAME": "{% if user.display_name %}{{ user.display_name }}{% endif %}",
|
||||
|
|
|
@ -101,8 +101,8 @@
|
|||
<div class="item">
|
||||
<div class="right floated content">
|
||||
<div class="ui buttons">
|
||||
<a class="ui button primary" href="{{ url_for("admin.invitation_txt", user_name=user.user_name, email=user.email[0]) }}">TXT</a>
|
||||
<a class="ui button primary" href="{{ url_for("admin.invitation_html", user_name=user.user_name, email=user.email[0]) }}">HTML</a>
|
||||
<a class="ui button primary" href="{{ url_for("admin.invitation_txt", user_name=user.user_name, email=user.emails[0]) }}">TXT</a>
|
||||
<a class="ui button primary" href="{{ url_for("admin.invitation_html", user_name=user.user_name, email=user.emails[0]) }}">HTML</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="middle aligned content">
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
{% if user.can_read("family_name") or user.can_read("given_name") %}
|
||||
<th>{% trans %}Name{% endtrans %}</th>
|
||||
{% endif %}
|
||||
{% if user.can_read("email") %}
|
||||
{% if user.can_read("emails") %}
|
||||
<th>{% trans %}Email{% endtrans %}</th>
|
||||
{% endif %}
|
||||
{% if user.can_manage_groups %}
|
||||
|
@ -41,8 +41,8 @@
|
|||
{% if user.can_read("family_name") or user.can_read("given_name") %}
|
||||
<td>{{ watched_user.formatted_name[0] }}</td>
|
||||
{% endif %}
|
||||
{% if user.can_read("email") %}
|
||||
<td><a href="mailto:{{ watched_user.email[0] }}">{{ watched_user.email[0] }}</a></td>
|
||||
{% if user.can_read("emails") %}
|
||||
<td><a href="mailto:{{ watched_user.emails[0] }}">{{ watched_user.emails[0] }}</a></td>
|
||||
{% endif %}
|
||||
{% if user.can_manage_groups %}
|
||||
<td>
|
||||
|
|
|
@ -142,8 +142,8 @@
|
|||
|
||||
{% if "photo" in form %}</div></div>{% endif %}
|
||||
|
||||
{% if "email" in form %}
|
||||
{% block email_field scoped %}{{ render_input(form.email) }}{% endblock %}
|
||||
{% if "emails" in form %}
|
||||
{% block emails_field scoped %}{{ render_input(form.emails) }}{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
{% if "phone_number" in form %}
|
||||
|
|
|
@ -114,8 +114,8 @@
|
|||
|
||||
{% if "photo" in form %}</div></div>{% endif %}
|
||||
|
||||
{% if "email" in form %}
|
||||
{% block email_field scoped %}{{ render_input(form.email) }}{% endblock %}
|
||||
{% if "emails" in form %}
|
||||
{% block emails_field scoped %}{{ render_input(form.emails) }}{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
{% if "phone_number" in form %}
|
||||
|
|
|
@ -139,7 +139,7 @@ WRITE = [
|
|||
"display_name",
|
||||
"password",
|
||||
"phone_number",
|
||||
"email",
|
||||
"emails",
|
||||
"profile_url",
|
||||
"formatted_address",
|
||||
"street",
|
||||
|
@ -209,7 +209,7 @@ PUBLIC_KEY = "conf/public.pem"
|
|||
# SUB = "{{ user.user_name[0] }}"
|
||||
# NAME = "{{ user.formatted_name[0] }}"
|
||||
# PHONE_NUMBER = "{{ user.phone_number[0] }}"
|
||||
# EMAIL = "{{ user.email[0] }}"
|
||||
# EMAIL = "{{ user.emails[0] }}"
|
||||
# GIVEN_NAME = "{{ user.given_name[0] }}"
|
||||
# FAMILY_NAME = "{{ user.family_name[0] }}"
|
||||
# PREFERRED_USERNAME = "{{ user.display_name }}"
|
||||
|
|
|
@ -139,7 +139,7 @@ WRITE = [
|
|||
"display_name",
|
||||
"password",
|
||||
"phone_number",
|
||||
"email",
|
||||
"emails",
|
||||
"profile_url",
|
||||
"formatted_address",
|
||||
"street",
|
||||
|
@ -210,7 +210,7 @@ PUBLIC_KEY = "conf/public.pem"
|
|||
# SUB = "{{ user.user_name[0] }}"
|
||||
# NAME = "{{ user.formatted_name[0] }}"
|
||||
# PHONE_NUMBER = "{{ user.phone_number[0] }}"
|
||||
# EMAIL = "{{ user.email[0] }}"
|
||||
# EMAIL = "{{ user.emails[0] }}"
|
||||
# GIVEN_NAME = "{{ user.given_name[0] }}"
|
||||
# FAMILY_NAME = "{{ user.family_name[0] }}"
|
||||
# PREFERRED_USERNAME = "{{ user.display_name }}"
|
||||
|
|
|
@ -22,7 +22,7 @@ def populate(app):
|
|||
family_name="Doe",
|
||||
user_name="admin",
|
||||
display_name="Jane.D",
|
||||
email="admin@mydomain.tld",
|
||||
emails="admin@mydomain.tld",
|
||||
password="admin",
|
||||
phone_number="555-000-000",
|
||||
profile_url="https://admin.example",
|
||||
|
@ -42,7 +42,7 @@ def populate(app):
|
|||
family_name="Doe",
|
||||
user_name="moderator",
|
||||
display_name="👮 Jack 👮",
|
||||
email="moderator@mydomain.tld",
|
||||
emails="moderator@mydomain.tld",
|
||||
password="moderator",
|
||||
phone_number="555-000-002",
|
||||
profile_url="https://moderator.example",
|
||||
|
@ -57,7 +57,7 @@ def populate(app):
|
|||
family_name="Doe",
|
||||
user_name="user",
|
||||
display_name="Johnny",
|
||||
email="user@mydomain.tld",
|
||||
emails="user@mydomain.tld",
|
||||
password="user",
|
||||
phone_number="555-000-001",
|
||||
profile_url="https://user.example",
|
||||
|
@ -71,7 +71,7 @@ def populate(app):
|
|||
given_name="James",
|
||||
family_name="Doe",
|
||||
user_name="james",
|
||||
email="james@mydomain.tld",
|
||||
emails="james@mydomain.tld",
|
||||
)
|
||||
james.save()
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ def test_form_translations(testclient, logged_user):
|
|||
logged_user.save()
|
||||
|
||||
res = testclient.get("/profile/user", status=200)
|
||||
res.form["email"] = "invalid"
|
||||
res.form["emails"] = "invalid"
|
||||
res = res.form.submit(name="action", value="edit")
|
||||
|
||||
res.mustcontain(no="Invalid email address.")
|
||||
|
|
|
@ -19,7 +19,7 @@ def test_object_creation(app, backend):
|
|||
formatted_name="Doe", # leading space
|
||||
family_name="Doe",
|
||||
user_name="user",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
)
|
||||
assert not user.exists
|
||||
user.save()
|
||||
|
@ -41,7 +41,7 @@ def test_dn_when_leading_space_in_id_attribute(backend):
|
|||
formatted_name=" Doe", # leading space
|
||||
family_name="Doe",
|
||||
user_name="user",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
)
|
||||
user.save()
|
||||
|
||||
|
@ -57,7 +57,7 @@ def test_dn_when_ldap_special_char_in_id_attribute(backend):
|
|||
formatted_name="#Doe", # special char
|
||||
family_name="Doe",
|
||||
user_name="user",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
)
|
||||
user.save()
|
||||
|
||||
|
|
|
@ -62,29 +62,29 @@ def test_model_attribute_edition(testclient, backend):
|
|||
family_name="family_name",
|
||||
formatted_name="formatted_name",
|
||||
display_name="display_name",
|
||||
email=["email1@user.com", "email2@user.com"],
|
||||
emails=["email1@user.com", "email2@user.com"],
|
||||
)
|
||||
user.save()
|
||||
|
||||
assert user.user_name == ["user_name"]
|
||||
assert user.family_name == ["family_name"]
|
||||
assert user.email == ["email1@user.com", "email2@user.com"]
|
||||
assert user.emails == ["email1@user.com", "email2@user.com"]
|
||||
|
||||
user = models.User.get(id=user.id)
|
||||
assert user.user_name == ["user_name"]
|
||||
assert user.family_name == ["family_name"]
|
||||
assert user.email == ["email1@user.com", "email2@user.com"]
|
||||
assert user.emails == ["email1@user.com", "email2@user.com"]
|
||||
|
||||
user.family_name = ["new_family_name"]
|
||||
user.email = ["email1@user.com"]
|
||||
user.emails = ["email1@user.com"]
|
||||
user.save()
|
||||
|
||||
assert user.family_name == ["new_family_name"]
|
||||
assert user.email == ["email1@user.com"]
|
||||
assert user.emails == ["email1@user.com"]
|
||||
|
||||
user = models.User.get(id=user.id)
|
||||
assert user.family_name == ["new_family_name"]
|
||||
assert user.email == ["email1@user.com"]
|
||||
assert user.emails == ["email1@user.com"]
|
||||
|
||||
user.display_name = [""]
|
||||
user.save()
|
||||
|
@ -99,40 +99,40 @@ def test_model_indexation(testclient, backend):
|
|||
user_name="user_name",
|
||||
family_name="family_name",
|
||||
formatted_name="formatted_name",
|
||||
email=["email1@user.com", "email2@user.com"],
|
||||
emails=["email1@user.com", "email2@user.com"],
|
||||
)
|
||||
user.save()
|
||||
|
||||
assert models.User.get(family_name="family_name") == user
|
||||
assert not models.User.get(family_name="new_family_name")
|
||||
assert models.User.get(email="email1@user.com") == user
|
||||
assert models.User.get(email="email2@user.com") == user
|
||||
assert not models.User.get(email="email3@user.com")
|
||||
assert models.User.get(emails="email1@user.com") == user
|
||||
assert models.User.get(emails="email2@user.com") == user
|
||||
assert not models.User.get(emails="email3@user.com")
|
||||
|
||||
user.family_name = "new_family_name"
|
||||
user.email = ["email2@user.com"]
|
||||
user.emails = ["email2@user.com"]
|
||||
|
||||
assert models.User.get(family_name="family_name") != user
|
||||
assert not models.User.get(family_name="new_family_name")
|
||||
assert models.User.get(email="email1@user.com") != user
|
||||
assert models.User.get(email="email2@user.com") != user
|
||||
assert not models.User.get(email="email3@user.com")
|
||||
assert models.User.get(emails="email1@user.com") != user
|
||||
assert models.User.get(emails="email2@user.com") != user
|
||||
assert not models.User.get(emails="email3@user.com")
|
||||
|
||||
user.save()
|
||||
|
||||
assert not models.User.get(family_name="family_name")
|
||||
assert models.User.get(family_name="new_family_name") == user
|
||||
assert not models.User.get(email="email1@user.com")
|
||||
assert models.User.get(email="email2@user.com") == user
|
||||
assert not models.User.get(email="email3@user.com")
|
||||
assert not models.User.get(emails="email1@user.com")
|
||||
assert models.User.get(emails="email2@user.com") == user
|
||||
assert not models.User.get(emails="email3@user.com")
|
||||
|
||||
user.delete()
|
||||
|
||||
assert not models.User.get(family_name="family_name")
|
||||
assert not models.User.get(family_name="new_family_name")
|
||||
assert not models.User.get(email="email1@user.com")
|
||||
assert not models.User.get(email="email2@user.com")
|
||||
assert not models.User.get(email="email3@user.com")
|
||||
assert not models.User.get(emails="email1@user.com")
|
||||
assert not models.User.get(emails="email2@user.com")
|
||||
assert not models.User.get(emails="email3@user.com")
|
||||
|
||||
|
||||
def test_fuzzy(user, moderator, admin, backend):
|
||||
|
|
|
@ -23,7 +23,7 @@ def configuration(smtpd):
|
|||
"READ": ["user_name", "groups"],
|
||||
"PERMISSIONS": ["edit_self", "use_oidc", "lock_date"],
|
||||
"WRITE": [
|
||||
"email",
|
||||
"emails",
|
||||
"given_name",
|
||||
"photo",
|
||||
"family_name",
|
||||
|
@ -100,7 +100,7 @@ def user(app, backend):
|
|||
given_name="John",
|
||||
family_name="Doe",
|
||||
user_name="user",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
password="correct horse battery staple",
|
||||
display_name="Johnny",
|
||||
preferred_language="en",
|
||||
|
@ -119,7 +119,7 @@ def admin(app, backend):
|
|||
formatted_name="Jane Doe",
|
||||
family_name="Doe",
|
||||
user_name="admin",
|
||||
email="jane@doe.com",
|
||||
emails="jane@doe.com",
|
||||
password="admin",
|
||||
)
|
||||
u.save()
|
||||
|
@ -133,7 +133,7 @@ def moderator(app, backend):
|
|||
formatted_name="Jack Doe",
|
||||
family_name="Doe",
|
||||
user_name="moderator",
|
||||
email="jack@doe.com",
|
||||
emails="jack@doe.com",
|
||||
password="moderator",
|
||||
)
|
||||
u.save()
|
||||
|
|
|
@ -132,7 +132,7 @@ def test_user_without_password_first_login(testclient, backend, smtpd):
|
|||
formatted_name="Temp User",
|
||||
family_name="Temp",
|
||||
user_name="temp",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
)
|
||||
u.save()
|
||||
|
||||
|
@ -166,7 +166,7 @@ def test_first_login_account_initialization_mail_sending_failed(
|
|||
formatted_name="Temp User",
|
||||
family_name="Temp",
|
||||
user_name="temp",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
)
|
||||
u.save()
|
||||
|
||||
|
@ -188,7 +188,7 @@ def test_first_login_form_error(testclient, backend, smtpd):
|
|||
formatted_name="Temp User",
|
||||
family_name="Temp",
|
||||
user_name="temp",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
)
|
||||
u.save()
|
||||
|
||||
|
@ -210,7 +210,7 @@ def test_user_password_deleted_during_login(testclient, backend):
|
|||
formatted_name="Temp User",
|
||||
family_name="Temp",
|
||||
user_name="temp",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
password="correct horse battery staple",
|
||||
)
|
||||
u.save()
|
||||
|
@ -234,7 +234,7 @@ def test_user_deleted_in_session(testclient, backend):
|
|||
formatted_name="Jake Doe",
|
||||
family_name="Jake",
|
||||
user_name="jake",
|
||||
email="jake@doe.com",
|
||||
emails="jake@doe.com",
|
||||
password="correct horse battery staple",
|
||||
)
|
||||
u.save()
|
||||
|
@ -298,7 +298,7 @@ def test_admin_self_deletion(testclient, backend):
|
|||
formatted_name="Temp admin",
|
||||
family_name="admin",
|
||||
user_name="temp",
|
||||
email="temp@temp.com",
|
||||
emails="temp@temp.com",
|
||||
password="admin",
|
||||
)
|
||||
admin.save()
|
||||
|
@ -323,7 +323,7 @@ def test_user_self_deletion(testclient, backend):
|
|||
formatted_name="Temp user",
|
||||
family_name="user",
|
||||
user_name="temp",
|
||||
email="temp@temp.com",
|
||||
emails="temp@temp.com",
|
||||
password="correct horse battery staple",
|
||||
)
|
||||
user.save()
|
||||
|
|
|
@ -52,7 +52,7 @@ def test_group_deletion(testclient, backend):
|
|||
formatted_name="foobar",
|
||||
family_name="foobar",
|
||||
user_name="foobar",
|
||||
email="foo@bar.com",
|
||||
emails="foo@bar.com",
|
||||
)
|
||||
user.save()
|
||||
|
||||
|
@ -112,7 +112,7 @@ def test_set_groups_with_leading_space_in_user_id_attribute(app, foo_group):
|
|||
formatted_name=" Doe", # leading space in id attribute
|
||||
family_name="Doe",
|
||||
user_name="user2",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
)
|
||||
user.save()
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ def test_invitation(testclient, logged_admin, foo_group, smtpd):
|
|||
|
||||
assert res.form["user_name"].value == "someone"
|
||||
assert res.form["user_name"].attrs["readonly"]
|
||||
assert res.form["email"].value == "someone@domain.tld"
|
||||
assert res.form["emails"].value == "someone@domain.tld"
|
||||
assert res.form["groups"].value == [foo_group.id]
|
||||
|
||||
res.form["password1"] = "whatever"
|
||||
|
@ -75,7 +75,7 @@ def test_invitation_editable_user_name(testclient, logged_admin, foo_group, smtp
|
|||
|
||||
assert res.form["user_name"].value == "jackyjack"
|
||||
assert "readonly" not in res.form["user_name"].attrs
|
||||
assert res.form["email"].value == "jackyjack@domain.tld"
|
||||
assert res.form["emails"].value == "jackyjack@domain.tld"
|
||||
assert res.form["groups"].value == [foo_group.id]
|
||||
|
||||
res.form["user_name"] = "djorje"
|
||||
|
@ -120,7 +120,7 @@ def test_generate_link(testclient, logged_admin, foo_group, smtpd):
|
|||
res = testclient.get(url, status=200)
|
||||
|
||||
assert res.form["user_name"].value == "sometwo"
|
||||
assert res.form["email"].value == "sometwo@domain.tld"
|
||||
assert res.form["emails"].value == "sometwo@domain.tld"
|
||||
assert res.form["groups"].value == [foo_group.id]
|
||||
|
||||
res.form["password1"] = "whatever"
|
||||
|
@ -148,7 +148,7 @@ def test_invitation_login_already_taken(testclient, logged_admin):
|
|||
res = testclient.get("/invite", status=200)
|
||||
|
||||
res.form["user_name"] = logged_admin.user_name
|
||||
res.form["email"] = logged_admin.email[0]
|
||||
res.form["email"] = logged_admin.emails[0]
|
||||
res = res.form.submit(name="action", value="send", status=200)
|
||||
|
||||
res.mustcontain("The login 'admin' already exists")
|
||||
|
|
|
@ -29,7 +29,7 @@ def test_user_has_password(testclient, backend):
|
|||
formatted_name="Temp User",
|
||||
family_name="Temp",
|
||||
user_name="temp",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
)
|
||||
u.save()
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from canaille.core.account import profile_hash
|
|||
|
||||
def test_password_reset(testclient, user):
|
||||
assert not user.check_password("foobarbaz")[0]
|
||||
hash = profile_hash("user", user.email[0], user.password[0])
|
||||
hash = profile_hash("user", user.emails[0], user.password[0])
|
||||
|
||||
res = testclient.get("/reset/user/" + hash, status=200)
|
||||
|
||||
|
@ -31,7 +31,7 @@ def test_password_reset_bad_link(testclient, user):
|
|||
|
||||
|
||||
def test_password_reset_bad_password(testclient, user):
|
||||
hash = profile_hash("user", user.email[0], user.password[0])
|
||||
hash = profile_hash("user", user.emails[0], user.password[0])
|
||||
|
||||
res = testclient.get("/reset/user/" + hash, status=200)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ def test_user_creation_edition_and_deletion(
|
|||
res.form["user_name"] = "george"
|
||||
res.form["given_name"] = "George"
|
||||
res.form["family_name"] = "Abitbol"
|
||||
res.form["email"] = "george@abitbol.com"
|
||||
res.form["emails"] = "george@abitbol.com"
|
||||
res.form["phone_number"] = "555-666-888"
|
||||
res.form["groups"] = [foo_group.id]
|
||||
res.form["password1"] = "totoyolo"
|
||||
|
@ -70,11 +70,11 @@ def test_profile_creation_dynamic_validation(testclient, logged_admin, user):
|
|||
"/profile",
|
||||
{
|
||||
"csrf_token": res.form["csrf_token"].value,
|
||||
"email": "john@doe.com",
|
||||
"emails": "john@doe.com",
|
||||
},
|
||||
headers={
|
||||
"HX-Request": "true",
|
||||
"HX-Trigger-Name": "email",
|
||||
"HX-Trigger-Name": "emails",
|
||||
},
|
||||
)
|
||||
res.mustcontain("The email 'john@doe.com' is already used")
|
||||
|
@ -102,7 +102,7 @@ def test_user_creation_without_password(testclient, logged_moderator):
|
|||
res = testclient.get("/profile", status=200)
|
||||
res.form["user_name"] = "george"
|
||||
res.form["family_name"] = "Abitbol"
|
||||
res.form["email"] = "george@abitbol.com"
|
||||
res.form["emails"] = "george@abitbol.com"
|
||||
|
||||
res = res.form.submit(name="action", value="edit", status=302)
|
||||
assert ("success", "User account creation succeed.") in res.flashes
|
||||
|
@ -133,7 +133,7 @@ def test_username_already_taken(
|
|||
res = testclient.get("/profile", status=200)
|
||||
res.form["user_name"] = "user"
|
||||
res.form["family_name"] = "foo"
|
||||
res.form["email"] = "any@thing.com"
|
||||
res.form["emails"] = "any@thing.com"
|
||||
res = res.form.submit(name="action", value="edit")
|
||||
assert ("error", "User account creation failed.") in res.flashes
|
||||
res.mustcontain("The login 'user' already exists")
|
||||
|
@ -143,7 +143,7 @@ def test_email_already_taken(testclient, logged_moderator, user, foo_group, bar_
|
|||
res = testclient.get("/profile", status=200)
|
||||
res.form["user_name"] = "user2"
|
||||
res.form["family_name"] = "foo"
|
||||
res.form["email"] = "john@doe.com"
|
||||
res.form["emails"] = "john@doe.com"
|
||||
res = res.form.submit(name="action", value="edit")
|
||||
assert ("error", "User account creation failed.") in res.flashes
|
||||
res.mustcontain("The email 'john@doe.com' is already used")
|
||||
|
@ -154,7 +154,7 @@ def test_cn_setting_with_given_name_and_surname(testclient, logged_moderator):
|
|||
res.form["user_name"] = "george"
|
||||
res.form["given_name"] = "George"
|
||||
res.form["family_name"] = "Abitbol"
|
||||
res.form["email"] = "george@abitbol.com"
|
||||
res.form["emails"] = "george@abitbol.com"
|
||||
|
||||
res = res.form.submit(name="action", value="edit", status=302).follow(status=200)
|
||||
|
||||
|
@ -167,7 +167,7 @@ def test_cn_setting_with_surname_only(testclient, logged_moderator):
|
|||
res = testclient.get("/profile", status=200)
|
||||
res.form["user_name"] = "george"
|
||||
res.form["family_name"] = "Abitbol"
|
||||
res.form["email"] = "george@abitbol.com"
|
||||
res.form["emails"] = "george@abitbol.com"
|
||||
|
||||
res = res.form.submit(name="action", value="edit", status=302).follow(status=200)
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ def test_edition(
|
|||
res.form["given_name"] = "given_name"
|
||||
res.form["family_name"] = "family_name"
|
||||
res.form["display_name"] = "display_name"
|
||||
res.form["email"] = "email@mydomain.tld"
|
||||
res.form["emails"] = "email@mydomain.tld"
|
||||
res.form["phone_number"] = "555-666-777"
|
||||
res.form["formatted_address"] = "formatted_address"
|
||||
res.form["street"] = "street"
|
||||
|
@ -129,7 +129,7 @@ def test_edition(
|
|||
assert logged_user.given_name == ["given_name"]
|
||||
assert logged_user.family_name == ["family_name"]
|
||||
assert logged_user.display_name == "display_name"
|
||||
assert logged_user.email == ["email@mydomain.tld"]
|
||||
assert logged_user.emails == ["email@mydomain.tld"]
|
||||
assert logged_user.phone_number == ["555-666-777"]
|
||||
assert logged_user.formatted_address == ["formatted_address"]
|
||||
assert logged_user.street == ["street"]
|
||||
|
@ -145,7 +145,7 @@ def test_edition(
|
|||
|
||||
logged_user.formatted_name = ["John (johnny) Doe"]
|
||||
logged_user.family_name = ["Doe"]
|
||||
logged_user.email = ["john@doe.com"]
|
||||
logged_user.emails = ["john@doe.com"]
|
||||
logged_user.given_name = None
|
||||
logged_user.photo = None
|
||||
logged_user.save()
|
||||
|
@ -171,7 +171,7 @@ def test_edition_remove_fields(
|
|||
|
||||
logged_user.formatted_name = ["John (johnny) Doe"]
|
||||
logged_user.family_name = ["Doe"]
|
||||
logged_user.email = ["john@doe.com"]
|
||||
logged_user.emails = ["john@doe.com"]
|
||||
logged_user.given_name = None
|
||||
logged_user.photo = None
|
||||
logged_user.save()
|
||||
|
@ -183,11 +183,11 @@ def test_profile_edition_dynamic_validation(testclient, logged_admin, user):
|
|||
"/profile/admin",
|
||||
{
|
||||
"csrf_token": res.form["csrf_token"].value,
|
||||
"email": "john@doe.com",
|
||||
"emails": "john@doe.com",
|
||||
},
|
||||
headers={
|
||||
"HX-Request": "true",
|
||||
"HX-Trigger-Name": "email",
|
||||
"HX-Trigger-Name": "emails",
|
||||
},
|
||||
)
|
||||
res.mustcontain("The email 'john@doe.com' is already used")
|
||||
|
@ -292,21 +292,21 @@ def test_admin_bad_request(testclient, logged_moderator):
|
|||
def test_bad_email(testclient, logged_user):
|
||||
res = testclient.get("/profile/user", status=200)
|
||||
|
||||
res.form["email"] = "john@doe.com"
|
||||
res.form["emails"] = "john@doe.com"
|
||||
|
||||
res = res.form.submit(name="action", value="edit").follow()
|
||||
|
||||
assert ["john@doe.com"] == logged_user.email
|
||||
assert ["john@doe.com"] == logged_user.emails
|
||||
|
||||
res = testclient.get("/profile/user", status=200)
|
||||
|
||||
res.form["email"] = "yolo"
|
||||
res.form["emails"] = "yolo"
|
||||
|
||||
res = res.form.submit(name="action", value="edit", status=200)
|
||||
|
||||
logged_user.reload()
|
||||
|
||||
assert ["john@doe.com"] == logged_user.email
|
||||
assert ["john@doe.com"] == logged_user.emails
|
||||
|
||||
|
||||
def test_surname_is_mandatory(testclient, logged_user):
|
||||
|
|
|
@ -108,7 +108,7 @@ def test_photo_on_profile_creation(testclient, jpeg_photo, logged_admin):
|
|||
res.form["photo"] = Upload("logo.jpg", jpeg_photo)
|
||||
res.form["user_name"] = "foobar"
|
||||
res.form["family_name"] = "Abitbol"
|
||||
res.form["email"] = "george@abitbol.com"
|
||||
res.form["emails"] = "george@abitbol.com"
|
||||
res = res.form.submit(name="action", value="edit", status=302).follow(status=200)
|
||||
|
||||
user = models.User.get_from_login("foobar")
|
||||
|
@ -126,7 +126,7 @@ def test_photo_deleted_on_profile_creation(testclient, jpeg_photo, logged_admin)
|
|||
res.form["photo_delete"] = True
|
||||
res.form["user_name"] = "foobar"
|
||||
res.form["family_name"] = "Abitbol"
|
||||
res.form["email"] = "george@abitbol.com"
|
||||
res.form["emails"] = "george@abitbol.com"
|
||||
res = res.form.submit(name="action", value="edit", status=302).follow(status=200)
|
||||
|
||||
user = models.User.get_from_login("foobar")
|
||||
|
|
|
@ -131,7 +131,7 @@ def test_password_initialization_mail(smtpd, testclient, backend, logged_admin):
|
|||
formatted_name="Temp User",
|
||||
family_name="Temp",
|
||||
user_name="temp",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
)
|
||||
u.save()
|
||||
|
||||
|
@ -142,7 +142,7 @@ def test_password_initialization_mail(smtpd, testclient, backend, logged_admin):
|
|||
res = res.form.submit(name="action", value="password-initialization-mail")
|
||||
assert (
|
||||
"success",
|
||||
"A password initialization link has been sent at the user email address. "
|
||||
"A password initialization link has been sent at the user.emails address. "
|
||||
"It should be received within a few minutes.",
|
||||
) in res.flashes
|
||||
assert len(smtpd.messages) == 1
|
||||
|
@ -167,7 +167,7 @@ def test_password_initialization_mail_send_fail(
|
|||
formatted_name="Temp User",
|
||||
family_name="Temp",
|
||||
user_name="temp",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
)
|
||||
u.save()
|
||||
|
||||
|
@ -180,7 +180,7 @@ def test_password_initialization_mail_send_fail(
|
|||
)
|
||||
assert (
|
||||
"success",
|
||||
"A password initialization link has been sent at the user email address. "
|
||||
"A password initialization link has been sent at the user.emails address. "
|
||||
"It should be received within a few minutes.",
|
||||
) not in res.flashes
|
||||
assert ("error", "Could not send the password initialization email") in res.flashes
|
||||
|
@ -237,7 +237,7 @@ def test_password_reset_email(smtpd, testclient, backend, logged_admin):
|
|||
formatted_name="Temp User",
|
||||
family_name="Temp",
|
||||
user_name="temp",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
password="correct horse battery staple",
|
||||
)
|
||||
u.save()
|
||||
|
@ -249,7 +249,7 @@ def test_password_reset_email(smtpd, testclient, backend, logged_admin):
|
|||
res = res.form.submit(name="action", value="password-reset-mail")
|
||||
assert (
|
||||
"success",
|
||||
"A password reset link has been sent at the user email address. "
|
||||
"A password reset link has been sent at the user.emails address. "
|
||||
"It should be received within a few minutes.",
|
||||
) in res.flashes
|
||||
assert len(smtpd.messages) == 1
|
||||
|
@ -265,7 +265,7 @@ def test_password_reset_email_failed(SMTP, smtpd, testclient, backend, logged_ad
|
|||
formatted_name="Temp User",
|
||||
family_name="Temp",
|
||||
user_name="temp",
|
||||
email="john@doe.com",
|
||||
emails="john@doe.com",
|
||||
password=["correct horse battery staple"],
|
||||
)
|
||||
u.save()
|
||||
|
@ -279,7 +279,7 @@ def test_password_reset_email_failed(SMTP, smtpd, testclient, backend, logged_ad
|
|||
)
|
||||
assert (
|
||||
"success",
|
||||
"A password reset link has been sent at the user email address. "
|
||||
"A password reset link has been sent at the user.emails address. "
|
||||
"It should be received within a few minutes.",
|
||||
) not in res.flashes
|
||||
assert ("error", "Could not send the password reset email") in res.flashes
|
||||
|
|
|
@ -814,7 +814,7 @@ def test_code_with_invalid_user(testclient, admin, client):
|
|||
formatted_name="John Doe",
|
||||
family_name="Doe",
|
||||
user_name="temp",
|
||||
email="temp@temp.com",
|
||||
emails="temp@temp.com",
|
||||
password="correct horse battery staple",
|
||||
)
|
||||
user.save()
|
||||
|
@ -862,7 +862,7 @@ def test_refresh_token_with_invalid_user(testclient, client):
|
|||
formatted_name="John Doe",
|
||||
family_name="Doe",
|
||||
user_name="temp",
|
||||
email="temp@temp.com",
|
||||
emails="temp@temp.com",
|
||||
password="correct horse battery staple",
|
||||
)
|
||||
user.save()
|
||||
|
|
|
@ -294,7 +294,7 @@ def test_custom_config_format_claim_is_well_formated(testclient, backend, user):
|
|||
def test_claim_is_omitted_if_empty(testclient, backend, user):
|
||||
# According to https://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse
|
||||
# it's better to not insert a null or empty string value
|
||||
user.email = ""
|
||||
user.emails = ""
|
||||
user.save()
|
||||
|
||||
data = generate_user_claims(user, STANDARD_CLAIMS, DEFAULT_JWT_MAPPING)
|
||||
|
|
Loading…
Reference in a new issue