{# -*- engine:django -*- #}
{% extends "two_factor/_base_focus.html" %}
{% load i18n two_factor %}

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

{% block content %}
  <h4>{% trans "Login" %}</h4>

  {% if wizard.steps.current == "auth" and user.is_authenticated %}
    <div class="alert warning">
      <p>
        <i class="material-icons left">warning</i>
        {% blocktrans %}You have no permission to view this page. Please login with an other account.{% endblocktrans %}
      </p>
    </div>
  {% else %}
    <div class="alert primary">
      <p>
        <i class="material-icons left">info</i>

        {% if wizard.steps.current == 'auth' %}
          {% blocktrans %}Please login to see this page.{% endblocktrans %}
        {% elif wizard.steps.current == 'token' %}
          {% if device.method == 'call' %}
            {% blocktrans %}We are calling your phone right now, please enter the
              digits you hear.{% endblocktrans %}
          {% elif device.method == 'sms' %}
            {% blocktrans %}We sent you a text message, please enter the tokens we
              sent.{% endblocktrans %}
          {% else %}
            {% blocktrans %}Please enter the tokens generated by your token
              generator.{% endblocktrans %}
          {% endif %}
        {% elif wizard.steps.current == 'backup' %}
          {% blocktrans %}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 %}
        {% endif %}
    </div>
  {% endif %}


  <form action="" method="post">
    {% csrf_token %}
    {% include "two_factor/_wizard_forms.html" %}

    {# hidden submit button to enable [enter] key #}
    <div style="margin-left: -9999px">
      <input type="submit" value=""/>
    </div>

    {% 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" 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="btn">{% trans "Use Backup Token" %}</button>
      </p>
    {% endif %}

    <button type="submit" class="btn green waves-effect waves-light">{% trans "Login" %}</button>

  </form>
{% endblock %}
