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

{% block content %}
  <h2 class="title is-5">{% block title %}{% trans "Account Security" %}{% endblock %}</h2>

  {% if default_device %}
    {% if default_device_type == 'TOTPDevice' %}
      <p class="subtitle">{% trans "Tokens will be generated by your token generator." %}</p>
    {% elif default_device_type == 'PhoneDevice' %}
      <p class="subtitle">{% blocktrans with primary=default_device.generate_challenge_button_title %}Primary method: {{ primary }}{% endblocktrans %}</p>
    {% elif default_device_type == 'RemoteYubikeyDevice' %}
      <p class="subtitle">{% blocktrans %}Tokens will be generated by your YubiKey.{% endblocktrans %}</p>
    {% endif %}

    {% if available_phone_methods %}
      <h2 class="title is-4">{% trans "Backup Phone Numbers" %}</h2>
      <p class="subtitle">{% blocktrans trimmed %}If your primary method is not available, we are able to
        send backup tokens to the phone numbers listed below.{% endblocktrans %}</p>
      <ul>
        {% for phone in backup_phones %}
          <li>
            {{ phone.generate_challenge_button_title }}
            <form method="post" action="{% url 'two_factor:phone_delete' phone.id %}"
                  onsubmit="return confirm({% trans 'Are you sure?' %})">
              {% csrf_token %}
              <button class="button is-warning"
                      type="submit">{% trans "Unregister" %}</button>
            </form>
          </li>
        {% endfor %}
      </ul>
      <p class="subtitle"><a href="{% url 'two_factor:phone_create' %}"
                             class="button">{% trans "Add Phone Number" %}</a></p>
    {% endif %}

    <h2 class="title is-4">{% trans "Backup Tokens" %}</h2>
    <p class="subtitle">
      {% blocktrans trimmed %}If you don't have any device with you, you can access
        your account using backup tokens.{% endblocktrans %}
      {% blocktrans trimmed count counter=backup_tokens %}
        You have only one backup token remaining.
      {% plural %}
        You have {{ counter }} backup tokens remaining.
      {% endblocktrans %}
    </p>
    <p class="subtitle"><a href="{% url 'two_factor:backup_tokens' %}"
                           class="button">{% trans "Show Codes" %}</a></p>

    <h3 class="title is-5">{% trans "Disable Two-Factor Authentication" %}</h3>
    <p class="subtitle">{% blocktrans trimmed %}However we strongly discourage you to do so, you can
      also disable two-factor authentication for your account.{% endblocktrans %}</p>
    <p class="subtitle"><a class="button" href="{% url 'two_factor:disable' %}">
      {% trans "Disable Two-Factor Authentication" %}</a></p>
  {% else %}
    <p class="subtitle">{% blocktrans trimmed %}Two-factor authentication is not enabled for your
      account. Enable two-factor authentication for enhanced account
      security.{% endblocktrans %}</p>
    <p class="subtitle"><a href="{% url 'two_factor:setup' %}" class="button">
      {% trans "Enable Two-Factor Authentication" %}</a>
    </p>
  {% endif %}
{% endblock %}
