{% extends "base.html" %}
{% load i18n %}

{% block title %}id.auf{% endblock %}

{% block contenthelp %}
<h2>Bonjour {{ request.user.username }}</h2>
<p>Vous pouvez désormais accéder vos services qui utilisent l'authentification unifiée, sans avoir à vous reconnecter à chaque fois.</p>
<p>Vous n'avez qu'a vous rendre sur la page du service et id.auf se charge de vous authentifier.</p>
<p>Utilisez le bouton «&nbsp;Déconnexion&nbsp;» pour vous déconnecter globalement de tous vos services.</p>
{% endblock %}

{% block content %}
{% if not request.user.username == '' %}
<a id="logout" href="{% url 'auth_logout' %}">Déconnexion</a>
{% endif %}

{% if account_management %}
<!--
<p>
  <a href="{% url 'account_management' %}">{% trans "Account Management" %}</a>
</p>
-->
{% endif %}

{% if authorized_services %}
  <div id="login-actions">
  <h2>Vos sites connectés</h2>
  <ul>
{% comment %}
    {% for service in authorized_services %}
    {% if service.actions %}
    <li>
    <div class="actions">
    {% for action in service.actions %}
      <form action="{{ action.2 }}" method="{{ action.1 }}">
        {% for key, value in action.3 %}
          <input type="hidden" name="{{ key }}" value="{{ value }}" />
        {% endfor %}
        <input type="hidden" name="next" value="/"/>
        <input type="submit" class="submit-link" value="{{ action.0 }}">
      </form>
    {% endfor %}
    </div>
    {% if service.url %}<a href="{{ service.url }}">{% endif %}{{ service.name }}{% if service.url %}</a>{% endif %} 
    </li>
    {% endif %}
    {% endfor %}
{% endcomment %}

{% comment %}
    {% for service in authorized_services %}
    {% if service.actions %}
    <li>
    <div class="actions">
    {% for action in service.actions %}
      <form action="{{ action.2 }}" method="{{ action.1 }}">
        {% for key, value in action.3 %}
          <input type="hidden" name="{{ key }}" value="{{ value }}" />
        {% endfor %}
        <input type="hidden" name="next" value="/"/>
        {% if action.0 == 'login' %}<input type="submit" class="submit-link login" value="→">{% else %}
{% if user.is_staff %}
        {% if action.0 == 'logout' %}<input type="submit" class="submit-link logout" value="X">{% else %}
        <input type="submit" class="submit-link" value="{{ action.0 }}">{% endif %}
{% endif %}
        {% endif %}
      </form>
    {% endfor %}
    </div>
    {% if service.url %}<a href="{{ service.url }}">{% endif %}{{ service.name }}{% if service.url %}</a>{% endif %} 
    </li>
    {% endif %}
    {% endfor %}
{% endcomment %}
    
    {% for service in authorized_services %}
    {% if service.actions %}
      {% for action in service.actions %}
      {% if action.0 == 'logout' %}<li>{{ service.name }}</li>{% endif %}
      {% endfor %}
    {% endif %}
    {% endfor %}
  </ul>
  </div>
{% endif %}

{% if user.is_staff %}
<p id="administration-link"><a href="/admin">{% trans "Administration" %}</a></p>
{% endif %}

{% endblock %}
