{% extends "iam/login.html.j2" %}
{% set subject=request.user %}
{% if subject.first_name and subject.last_name %}
{% set display_name=subject.first_name + " " + subject.last_name %}
{% endif %}


{% block main_content %}
<div class="row">
  <div class="col mx-auto w-100">
    <p>
      {% if display_name is defined %}
      {{ _("Welcome back, %(display_name)s.",
        display_name=('<strong>'+display_name+'</strong>')|safe) }}
      {% endif %}
      {{ _("Your password is expired. Use the form below to choose a new one.") }}
    </p>
    <form action="" method="POST">
      <div class="form-group">{{ csrf_input }}
        <input type="hidden" name="op" value="choosepassword"/>
        <input name="password1"
          type="password"
          required="true"
          {% if form.password1|default(None) %}
          class="form-control{% if form.password1.errors %} is-invalid{% endif %}"
          {% else %}
          class="form-control"
          {% endif %}
          maxlength="64"
          placeholder="{{ _('New password') }}"
          {% if form.password1|default(None) and form.password1.value() %}
          value="{{ form.password1.value() }}"
          {% endif %}
        />
        {% if form.password1|default(None) and form.password1.errors %}
        <p class="invalid-feedback">{{ form.password1.errors[0] }}</p>
        {% endif %}
      </div>
      <div class="form-group">
        <input name="password2"
          type="password"
          required="true"
          {% if form.password2|default(None) %}
          class="form-control{% if form.password2.errors %} is-invalid{% endif %}"
          {% else %}
          class="form-control"
          {% endif %}
          maxlength="64"
          placeholder="{{ _('New password (again)') }}"
          {% if form.password2|default(None) and form.password2.value() %}
          value="{{ form.password2.value() }}"
          {% endif %}
        />
        {% if form.password2|default(None) and form.password2.errors %}
        <p class="invalid-feedback">{{ form.password2.errors[0] }}</p>
        {% endif %}
      </div>
      <button type="submit" class="btn btn-primary w-100">
        {{ _('Set my password') }}
      </button>
    </form>
  </div>
</div>
<hr/>
<div class="row mb-1">
  <div class="col mx-auto">
    <a href="{{ url(iam_urls.logout) }}{{ next_url }}"
      class="btn btn-outline-primary w-100" role="button">
      <i class="fas fa-angle-left"></i> {{ _("Logout and return to login options") }}
    </a>
  </div>
</div>
{% endblock %}

