{% extends "layout/base.html" %}
{% load i18n %}
{% load static %}

{% block content %}
  {% if user.is_authenticated %}
    <h1>{% trans "You are logged in." %}</h1>
    {% if two_factor_enabled %}
      <p>
        {% translate 'Two factor authentication is enabled for your account.' %}
      </p>
    {% else %}
      <p>
        {% translate 'Two factor authentication is not enabled for your account. Enable it to continue.' %}
      </p>
      <a class="button" href="{% url 'setup' %}" class="a-button">{% trans "Setup two factor authentication" %}</a>
    {% endif %}
  {% else %}
    <section class="form-view">
      <div>
        <h1>{% translate 'Login' %}</h1>
        <form action="" method="post" class="help">
          {% csrf_token %}
          <fieldset>
            {% if wizard.steps.current == 'auth' %}
              <legend>
                {% translate 'Credentials' %}
              </legend>
            {% elif wizard.steps.current == 'token' %}
              <p class="explanation"
                 role="group"
                 aria-label="{% translate 'explanation' %}">
                <span>{% translate 'Explanation' %}:</span>
                {% translate 'Please enter the token generated by your token generator.' %}
              </p>
            {% elif wizard.steps.current == 'backup' %}
              <p class="explanation"
                 role="group"
                 aria-label="{% translate 'explanation' %}">
                <span>{% translate 'Explanation' %}:</span>
                {% 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 %}
            {% include 'partials/form/form_errors.html' %}
            {% include "two_factor/_wizard_forms.html" with step=wizard.steps.current %}
            {# hidden submit button to enable [enter] key #}
            <input type="submit" value="" class="d-none" />
            {% 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="secondary">
                  {% translate 'Use Backup Token' %}
                </button>
              </p>
            {% endif %}
            {% include "two_factor/_wizard_actions.html" with step=wizard.steps.current %}
          </fieldset>
        </form>
      </div>
    </section>
  {% endif %}
{% endblock %}
