{% extends "authentic2/base-page.html" %}
{% load i18n static %}

{% block extra-top-head %}
 {{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static 'authentic2_idp_oidc/css/style.css' %}"></link>
{% endblock %}

{% block content %}
<h2>{% trans "Authentication access check" %}</h2>
<form method="post" id="a2-oidc-authorization-form">
    <p>{% blocktrans with client_name=client.name %}Do you want to be authenticated on service {{ client_name }} ?{% endblocktrans %}</p>
    {% if needs_scope_validation %}
      <p>{% trans "The following informations will be sent to the service:" %}</p>
      <ul>
        {% for scope in scopes %}
          {% if scope == "profile" %}
            <li>{% trans "Your first and last name, your username" %}</li>
          {% elif scope == "email" %}
            <li>{% trans "Your email:" %} {{ user.email }}</li>
          {% endif %}
        {% endfor %}
      </ul>
    {% endif %}
    {% if needs_profile_validation %}
     <div id="profile-validation">
     <p>{% trans "You may authenticate as owner of the following juridical entity management profile, which may change the aforementioned information." %}</p>
      <div class="profile" id="profile-validation-none">
        <input type="radio" id="_none" name="profile-validation" value="" checked>
        <label for="_none">{% trans "Keep my default user profile." %}</label>
      </div>
      {% for profile in user.profiles.all %}
        <div class="profile" id="profile-validation-{{ profile.id }}">
          <input type="radio" id="{{ profile.id }}" name="profile-validation" value="{{ profile.id }}">
          <label for="{{ profile.id }}">
          {% with identifier=profile.identifier type_name=profile.profile_type.name %}
            {% trans "Unknown entity" as fallback_identifier %}
            {% blocktrans %}Profile of type {{ type_name }}: {% endblocktrans %}
            {% firstof identifier fallback_identifier %}<br />
          {% endwith %}
          {% if profile.email %}
            {% blocktrans with email=profile.email %}Email address: {{ email }}{% endblocktrans %}<br />
          {% endif %}</label>
        </div>
      {% endfor %}
     </div>
    {% endif %}
    {% csrf_token %}
    <p class="a2-oidc-authorization-form--do-not-ask-again">
      <label for="id_do_not_ask_again"><input id="id_do_not_ask_again" type="checkbox" name="do_not_ask_again" value="on"/><span>{% trans "Do not ask again" %}</span></label>
    </p>
    <div class="buttons">
    <button name="accept">{% trans "Accept" %}</button>
    <button name="refuse">{% trans "Refuse" %}</button>
    </div>
  </form>
{% endblock %}
