{% extends "two_factor/admin/_base.html" %}
{% load i18n two_factor %}

{% block nav-global %}{% endblock %}
{% block django_admin_index_menu %}{% endblock %}
{% block breadcrumbs %}{% endblock %}

{% block header %}{% trans "Login" %}{% endblock header %}

{% block content %}
  {% if wizard.steps.current == 'auth' %}
    <p>{% blocktrans %}Enter your credentials.{% endblocktrans %}</p>
  {% elif wizard.steps.current == 'token' %}
    {% if device.method == 'call' %}
      <p>{% blocktrans trimmed %}We are calling your phone right now, please enter the
        digits you hear.{% endblocktrans %}</p>
    {% elif device.method == 'sms' %}
      <p>{% blocktrans trimmed %}We sent you a text message, please enter the tokens we
        sent.{% endblocktrans %}</p>
    {% else %}
      <p>{% blocktrans trimmed %}Please enter the tokens generated by your token
        generator.{% endblocktrans %}</p>
    {% endif %}
  {% elif wizard.steps.current == 'backup' %}
    <p>{% blocktrans trimmed %}Use this form for entering backup tokens for logging in.
      These tokens have been generated for you to print and keep safe. Please
      enter one of these backup tokens to login to your account.{% endblocktrans %}</p>
  {% endif %}

  <form action="" method="post">{% csrf_token %}
    {% if wizard.steps.current == 'auth' %}
      {{ wizard.management_form }}
      {{ wizard.form.non_field_errors }}
      <div class="form-row">
        {{ form.username.errors }}
        {{ form.username.label_tag }} <input type="text" name="auth-username" autofocus="" required="" id="id_username">
      </div>
      <div class="form-row">
        {{ form.password.errors }}
        {{ form.password.label_tag }} <input type="password" name="auth-password" autocomplete="current-password" required="" id="id_password">
        <input type="hidden" name="next" value="{{ next }}">
      </div>
    {% else %}
        {% include "two_factor/admin/_wizard_forms.html" %}
    {% endif %}

    {# hidden submit button to enable [enter] key #}
    <input hidden type="submit" value="" />

    {% if other_devices %}
      <p>{% trans "Or, alternatively, use one of your backup phones:" %}</p>
      <p>
        {% for other in other_devices %}
        <button name="challenge_device" value="{{ other.persistent_id }}"
                class="btn btn-secondary btn-block" type="submit">
          {{ other|device_action }}
        </button>
      {% endfor %}</p>
    {% endif %}
    {% if backup_tokens %}
      <p>{% trans "As a last resort, you can use a backup token:" %}</p>
      <p>
        <button name="wizard_goto_step" type="submit" value="backup"
                class="button button-with-padding">{% trans "Use Backup Token" %}</button>
      </p>
    {% endif %}


    {% if wizard.steps.current == 'auth' %}
    <div class="password-reset-link">
        <a href="/admin/password_reset/">Forgotten your password or username?</a>
    </div>
    <div class="actions-buttons">
      <input type="submit" value="{% trans 'Login' %}">
    </div>

    {% else %}
      {% include "two_factor/admin/_wizard_actions.html" %}
    {% endif %}
  </form>
{% endblock %}
