2024-12-16 17:17:42 +00:00
{# The profile settings template.
Displays the user settings edition form.
:param edited_user: The user that the form will edit.
:type edited_user: :class:`~canaille.core.models.User`
:param form: The user profile edition form. Dynamically built according to the user :attr:`~canaille.core.configuration.ACLSettings.READ` and :attr:`~canaille.core.configuration.ACLSettings.WRITE` permissions. The available fields are those appearing in *READ* and *WRITE*, those only appearing in *READ* are read-only.
:type form: :class:`~flask_wtf.FlaskForm`
:param self_deletion: Whether the editor is allowed to delete the account of the edited user.
:type self_deletion: :class:`bool`
#}
2021-10-28 13:24:34 +00:00
{% extends theme('base.html') %}
2023-03-28 18:37:16 +00:00
{% import 'macro/form.html' as fui %}
2020-10-20 09:44:45 +00:00
2023-03-16 18:30:30 +00:00
{%- block title -%}
2023-02-05 17:57:18 +00:00
{% if user.user_name == edited_user.user_name %}
2023-03-16 18:30:30 +00:00
{%- trans %}My profile{% endtrans -%}
2023-03-10 00:02:36 +00:00
{% else %}
2023-03-16 18:30:30 +00:00
{%- trans %}User profile edition{% endtrans -%}
2023-03-10 00:02:36 +00:00
{% endif %}
2023-03-16 18:30:30 +00:00
{%- endblock -%}
2023-03-10 00:02:36 +00:00
2023-03-15 16:27:32 +00:00
{% block submenu %}
2023-09-08 07:05:51 +00:00
< a class = "item" href = "{{ url_for('core.account.profile_edition', edited_user=edited_user) }}" >
< i class = "id card icon" > < / i >
{% trans %}Personal information{% endtrans %}
< / a >
< a class = "active item" href = "{{ url_for('core.account.profile_settings', edited_user=edited_user) }}" >
< i class = "tools icon" > < / i >
{% trans %}Account settings{% endtrans %}
< / a >
2023-03-15 16:27:32 +00:00
{% endblock %}
2023-06-22 13:51:53 +00:00
{% macro render_field(field, noindicator=false) %}
2021-12-06 11:17:18 +00:00
{% set lock_indicator = field.render_kw and ("readonly" in field.render_kw or "disabled" in field.render_kw) %}
2023-02-05 17:57:18 +00:00
{% if edited_user.user_name == user.user_name or lock_indicator or noindicator %}
2023-06-22 13:51:53 +00:00
{{ fui.render_field(field, **kwargs) }}
2024-04-07 13:21:32 +00:00
{% elif field.name in edited_user.writable_fields %}
2023-06-22 13:51:53 +00:00
{{ fui.render_field(field, **kwargs) }}
2024-04-07 13:21:32 +00:00
{% elif field.name in edited_user.readable_fields %}
2023-06-22 13:51:53 +00:00
{{ fui.render_field(field, indicator_icon="eye", indicator_text=_("This user cannot edit this field"), **kwargs) }}
2021-12-05 18:45:27 +00:00
{% else %}
2023-06-22 13:51:53 +00:00
{{ fui.render_field(field, indicator_icon="eye slash", indicator_text=_("This user cannot see this field"), **kwargs) }}
2021-12-05 18:45:27 +00:00
{% endif %}
{% endmacro %}
2020-10-20 09:44:45 +00:00
{% block content %}
2021-12-20 22:57:27 +00:00
< div class = "ui clearing segment" >
< h2 class = "ui center aligned header" >
< div class = "content" >
2023-06-30 16:10:16 +00:00
{% trans %}Account settings{% endtrans %}
2021-12-20 22:57:27 +00:00
< / div >
2024-03-27 12:53:46 +00:00
< div class = "sub header" title = "{{ edited_user.created|datetimeformat }}" >
{% trans creation_datetime=edited_user.created|dateformat %}Created on {{ creation_datetime }}{% endtrans %}
< / div >
2021-12-20 22:57:27 +00:00
< / h2 >
2023-03-28 21:12:54 +00:00
{% call fui.render_form(form, class_="profile-form info warning") %}
2023-07-28 17:17:26 +00:00
2023-02-05 17:57:18 +00:00
{% if "user_name" in form %}
2023-06-22 13:51:53 +00:00
{% block user_name_field scoped %}{{ render_field(form.user_name) }}{% endblock %}
2021-12-20 22:57:27 +00:00
{% endif %}
2021-12-01 11:19:28 +00:00
2024-05-14 20:53:47 +00:00
{% if features.has_account_lockability and "lock_date" in form and not edited_user.locked %}
2023-07-28 17:17:26 +00:00
{% block lock_date_field scoped %}{{ render_field(form.lock_date) }}{% endblock %}
{% endif %}
2021-12-20 22:57:27 +00:00
{% if "groups" in form %}
2023-06-22 13:51:53 +00:00
{% block groups_field scoped %}{{ render_field(form.groups) }}{% endblock %}
2021-12-20 22:57:27 +00:00
{% endif %}
2021-01-22 17:26:53 +00:00
2023-07-28 17:17:26 +00:00
< h2 class = "ui center aligned header" >
< div class = "content" >
{% trans %}Password{% endtrans %}
< / div >
< / h2 >
< div class = "ui info message" >
{% trans %}
You can change your password here by typing it once it each fields below.
The more a password is long, the more it is strong. A good password is a
long password that you will remember, not a complicated password that your
use for all your accounts.
{% endtrans %}
< / div >
2021-12-20 22:57:27 +00:00
{% if "password1" in form %}
{% block password_field scoped %}
< div class = "two fields" >
2023-06-22 13:51:53 +00:00
{{ render_field(form.password1, noindicator=true) }}
{{ render_field(form.password2, noindicator=true) }}
2021-12-20 22:57:27 +00:00
< / div >
{% endblock %}
{% endif %}
2021-12-01 11:19:28 +00:00
2021-12-20 22:57:27 +00:00
{% if user.can_manage_users %}
2023-03-17 08:27:48 +00:00
{% if not edited_user.has_password() %}
2021-12-20 22:57:27 +00:00
2022-11-09 17:03:13 +00:00
< div class = "ui message warning visible" >
2024-05-14 20:53:47 +00:00
{% if features.has_smtp and edited_user.can_edit_self %}
2022-11-16 17:19:24 +00:00
< button type = "submit" name = "action" value = "password-initialization-mail" class = "ui right floated primary button" >
2024-03-27 13:06:38 +00:00
{% trans %}Send mail{% endtrans %}
2022-11-16 17:19:24 +00:00
< / button >
2021-12-20 22:57:27 +00:00
{% endif %}
< div class = "header" >
{% trans %}This user does not have a password yet{% endtrans %}
< / div >
2024-05-14 20:53:47 +00:00
{% if features.has_smtp and edited_user.can_edit_self %}
2021-12-20 22:57:27 +00:00
< p > {% trans %}You can solve this by:{% endtrans %}< / p >
< ul class = "ui list" >
< li > {% trans %}setting a password using this form;{% endtrans %}< / li >
< li > {% trans %}sending the user a password initialization mail, by clicking this button;{% endtrans %}< / li >
< li > {% trans %}or simply waiting for the user to sign-in a first time, and then receive a password initialization mail.{% endtrans %}< / li >
< / ul >
{% else %}
< p > {% trans %}The user will not be able to authenticate unless the password is set{% endtrans %}< / p >
{% endif %}
< / div >
2024-05-14 20:53:47 +00:00
{% elif features.has_smtp and edited_user.user_name != user.user_name and edited_user.has_password() and edited_user.can_edit_self %}
2021-12-20 22:57:27 +00:00
< div class = "ui message info" >
< button type = "submit" name = "action" value = "password-reset-mail" class = "ui right floated button" >
2022-11-16 17:19:24 +00:00
{% trans %}Send mail{% endtrans %}
2021-12-07 15:39:18 +00:00
< / button >
2021-12-20 22:57:27 +00:00
< div class = "header" >
{% trans %}Password reset{% endtrans %}
< / div >
< p > {% trans %}If the user has forgotten his password, you can send him a password reset email by clicking this button.{% endtrans %}< / p >
< / div >
2021-12-01 11:19:28 +00:00
{% endif %}
2021-01-22 17:26:53 +00:00
2024-05-14 20:53:47 +00:00
{% if features.has_account_lockability and edited_user.locked %}
2022-11-01 11:25:21 +00:00
< div class = "ui message warning visible" >
< button type = "submit" name = "action" value = "unlock" class = "ui right floated button" >
{% trans %}Unlock{% endtrans %}
< / button >
< div class = "header" >
{% trans %}This user account is locked{% endtrans %}
< / div >
< p >
{% trans %}The user won't be able to connect until their account is unlocked.{% endtrans %}
< / p >
< / div >
{% endif %}
2020-11-26 14:29:14 +00:00
{% endif %}
2020-11-01 10:33:56 +00:00
2021-12-20 22:57:27 +00:00
< div class = "ui right aligned container" >
< div class = "ui stackable buttons" >
2024-11-14 08:49:19 +00:00
{% if features.has_otp and user.can_manage_users %}
2024-11-18 13:16:38 +00:00
< button type = "submit" class = "ui right floated basic negative button confirm" name = "action" value = "confirm-reset-otp" id = "reset-otp" formnovalidate >
{% trans %}Reset one-time password authentication{% endtrans %}
2024-11-14 08:49:19 +00:00
< / button >
{% endif %}
2024-05-14 20:53:47 +00:00
{% if features.has_account_lockability and "lock_date" in user.writable_fields and not edited_user.locked %}
2023-07-06 16:43:37 +00:00
< button type = "submit" class = "ui right floated basic negative button confirm" name = "action" value = "confirm-lock" id = "lock" formnovalidate >
2022-11-01 11:25:21 +00:00
{% trans %}Lock the account{% endtrans %}
< / button >
{% endif %}
2023-03-17 08:27:48 +00:00
{% if user.can_manage_users or self_deletion %}
2023-07-06 16:43:37 +00:00
< button type = "submit" class = "ui right floated basic negative button confirm" name = "action" value = "confirm-delete" id = "delete" formnovalidate >
2023-02-05 17:57:18 +00:00
{% if user.user_name != edited_user.user_name %}
2021-12-20 22:57:27 +00:00
{{ _("Delete the user") }}
{% else %}
{{ _("Delete my account") }}
{% endif %}
< / button >
2021-07-01 07:55:40 +00:00
{% endif %}
2024-04-12 10:12:08 +00:00
{% if user.can_impersonate_users and user.identifier != edited_user.identifier and not edited_user.locked %}
2023-08-14 11:52:24 +00:00
< a href = "{{ url_for('core.account.impersonate', puppet=edited_user) }}" class = "ui right floated basic button" name = "action" value = "impersonate" id = "impersonate" hx-boost = "false" >
2021-12-20 22:57:27 +00:00
{{ _("Impersonate") }}
< / a >
{% endif %}
2021-07-01 07:55:40 +00:00
2023-07-30 21:08:17 +00:00
< button type = "submit" class = "ui right floated primary button" name = "action" value = "edit-settings" id = "edit-settings" >
2023-07-07 08:06:01 +00:00
{{ _("Edit") }}
2021-12-20 22:57:27 +00:00
< / button >
2021-07-01 07:55:40 +00:00
2021-12-20 22:57:27 +00:00
< / div >
2021-07-01 07:55:40 +00:00
< / div >
2023-03-28 21:12:54 +00:00
{% endcall %}
2021-12-20 22:57:27 +00:00
< / div >
2020-10-20 09:44:45 +00:00
{% endblock %}