{% extends 'page.html' %}

{% import 'macros/form.html' as form %}

{% block subtitle %}{{ _('Manage 2FA') }}{% endblock %}

{% block breadcrumb_content %}
    <li><a href="{{ h.url_for('user.index') }}">{{ _('Users') }}</a></li>
    <li><a href="{{ h.url_for('user.read', id=user_dict.name) }}">{{ user_dict.display_name }}</a></li>
    <li class="active"><a href="#">{{ _('Manage 2FA') }}</a></li>
{% endblock %}

{% block secondary_content %}
    <section class="module module-narrow module-shallow">
        <h2 class="module-heading"><i class="fa fa-info-circle"></i> {{ _('Manage 2FA') }}</h2>
        <div class="module-content">
            <p>
                {{ _("Scan the image with the two factor authentication app on your phone.") }}
            </p>

            <p>
                <b>{{ _("Test") }}</b>:
                {{ _("Enter the two factor authentication code from your app to test correct configuration.") }}
            </p>
            <p>
                <b>{{ _("Regenerate secret") }}</b>:
                {{ _("You might need it if you lost an access to your 2FA device or want to setup another one.") }}
            </p>
        </div>
    </section>
{% endblock %}

{% block page_header %} {% endblock %}

{% block primary_content_inner %}
    <form id="mfa-form" method="POST">
        {{ h.csrf_input() }}

        {% snippet "auth/snippets/2fa_qr_code.html", totp_secret=totp_secret, provisioning_uri=provisioning_uri %}

        <div class="form-actions">
            <a class="btn btn-default m-0 me-auto" href="{{ h.url_for('user.edit', id=user_dict.name) }}">{{ _("Back") }}</a>

            <a class="btn btn-danger" href="{{ h.url_for('auth.regenerate_secret', user_id=user_id) }}" data-module="confirm-action"
                data-module-i18n="{{ h.dump_json({'content': _('Are you sure you want to generate a new 2FA secret?')}) }}">
                {{ _('Regenerate 2FA secret') }}
            </a>

            <button class="btn btn-primary" type="submit">{{_('Test')}}</button>
        </div>
    </form>
{% endblock %}
