Default configuration and test client use user avatars

This commit is contained in:
Éloi Rivard 2021-12-13 22:50:53 +01:00
parent 951fce2725
commit f4c04d9666
6 changed files with 79 additions and 57 deletions

View file

@ -519,7 +519,7 @@ def reset(uid, hash):
@bp.route("/profile/<uid>/<field>") @bp.route("/profile/<uid>/<field>")
def photo(uid, field): def photo(uid, field):
if field != "jpegPhoto": if field.lower() != "jpegphoto":
abort(404) abort(404)
user = User.get(uid) user = User.get(uid)

View file

@ -156,6 +156,7 @@ FAMILY_NAME = "{{ user.sn[0] }}"
PREFERRED_USERNAME = "{{ user.displayName[0] }}" PREFERRED_USERNAME = "{{ user.displayName[0] }}"
LOCALE = "{{ user.preferredLanguage[0] }}" LOCALE = "{{ user.preferredLanguage[0] }}"
ADDRESS = "{{ user.postalAddress[0] }}" ADDRESS = "{{ user.postalAddress[0] }}"
PICTURE = "{% if user.jpegPhoto %}{{ url_for('account.photo', uid=user.uid[0], field='jpegPhoto', _external=True) }}{% endif %}"
# The SMTP server options. If not set, mail related features such as # The SMTP server options. If not set, mail related features such as
# user invitations, and password reset emails, will be disabled. # user invitations, and password reset emails, will be disabled.

View file

@ -29,12 +29,12 @@
{% if user %} {% if user %}
<a class="item" href="{{ url_for('logout') }}"> <a class="item" href="{{ url_for('logout') }}">
<i class="sign out alternate icon"></i> <i class="sign out alternate icon"></i>
Log out Sign out
</a> </a>
{% else %} {% else %}
<a class="item" href="{{ url_for('login') }}"> <a class="item" href="{{ url_for('login') }}">
<i class="sign in alternate icon"></i> <i class="sign in alternate icon"></i>
Log in Sign in
</a> </a>
{% endif %} {% endif %}
</nav> </nav>
@ -50,17 +50,32 @@
<div class="ui segment"> <div class="ui segment">
<h2 class="ui header">{{ name }}</h2> <h2 class="ui header">{{ name }}</h2>
<div>
{% if user %} {% if user %}
<p>Welcome {{ user.name }}</p> <div class="ui centered card">
{% if user.groups %} {% if user.picture %}
<p>You're a member of the following groups: {{ user.groups }}</p> <div class="image">
<img src="{{ user.picture }}" alt="Avatar">
</div>
{% endif %} {% endif %}
{% else %} <div class="content">
Welcome, please <a href="{{ url_for('login') }}">log-in</a>. <span class="header">{{ user.name }}</span>
<div class="meta">
{{ user.sub }}
</div>
{% if user.groups %}
<div class="extra content">
<i class="user users icon"></i>
{% for group in user.groups %}
<span class="label">{{ group }}</span>
{% endfor %}
</div>
{% endif %} {% endif %}
</div> </div>
</div> </div>
{% else %}
<a class="ui primary button" href="{{ url_for('login') }}">Sign in</a>.
{% endif %}
</div>
</div> </div>
<script src="/static/jquery/jquery.min.js"></script> <script src="/static/jquery/jquery.min.js"></script>

View file

@ -162,6 +162,7 @@ FAMILY_NAME = "{{ user.sn[0] }}"
PREFERRED_USERNAME = "{{ user.displayName[0] }}" PREFERRED_USERNAME = "{{ user.displayName[0] }}"
LOCALE = "{{ user.preferredLanguage[0] }}" LOCALE = "{{ user.preferredLanguage[0] }}"
ADDRESS = "{{ user.postalAddress[0] }}" ADDRESS = "{{ user.postalAddress[0] }}"
PICTURE = "{% if user.jpegPhoto %}{{ url_for('account.photo', uid=user.uid[0], field='jpegPhoto', _external=True) }}{% endif %}"
# The SMTP server options. If not set, mail related features such as # The SMTP server options. If not set, mail related features such as
# user invitations, and password reset emails, will be disabled. # user invitations, and password reset emails, will be disabled.

View file

@ -212,6 +212,10 @@ Attributes are rendered using jinja2, and can use a ``user`` variable.
:ADDRESS: :ADDRESS:
*Optional.* Defaults to ``{{ user.postalAddress[0] }}`` *Optional.* Defaults to ``{{ user.postalAddress[0] }}``
:PICTURE:
*Optional.* Defaults to ``{% if user.jpegPhoto %}{{ url_for('account.photo', uid=user.uid[0], field='jpegPhoto', _external=True) }}{% endif %}``
SMTP SMTP
---- ----
Canaille needs you to configure a SMTP server to send some mails, including the *I forgot my password* and the *invitation* mails. Canaille needs you to configure a SMTP server to send some mails, including the *I forgot my password* and the *invitation* mails.

View file

@ -187,6 +187,7 @@ def configuration(slapd_server, smtpd, keypair_path):
"FAMILY_NAME": "{{ user.sn[0] }}", "FAMILY_NAME": "{{ user.sn[0] }}",
"PREFERRED_USERNAME": "{{ user.displayName[0] }}", "PREFERRED_USERNAME": "{{ user.displayName[0] }}",
"LOCALE": "{{ user.preferredLanguage[0] }}", "LOCALE": "{{ user.preferredLanguage[0] }}",
"PICTURE": "{% if user.jpegPhoto %}{{ url_for('account.photo', uid=user.uid[0], field='jpegPhoto', _external=True) }}{% endif %}",
}, },
}, },
"SMTP": { "SMTP": {