{# The multi-factor authentication code verification template.

Displays a form that asks for the multi-factor authentication code.

:param form: The code verification form.
:type form: :class:`~canaille.core.endpoints.forms.TwoFactorForm`
#}
{% extends theme('base.html') %}
{% import 'macro/flask.html' as flask %}
{% import 'macro/form.html' as fui %}
{% import 'core/partial/login_field.html' as login_field %}

{% block script %}
    <script src="{{ url_for("static", filename="js/verify-mfa.js") }}" defer></script>
{% endblock %}

{% block container %}
    <div class="ui container">
        <div class="content">
            <div class="ui clearing segment">
                {% block header %}
                    {% if logo_url %}
                        <a href="{{ url_for('core.account.index') }}">
                            <img class="ui tiny centered image" src="{{ logo_url }}" alt="{{ website_name }}">
                        </a>
                    {% else %}
                        <i class="massive sign in icon image ui"></i>
                    {% endif %}

                    <h2 class="ui center aligned header">
                        <div class="content">
                            {{ _("Sign in as %(username)s", username=g.auth.user_name) }}
                        </div>
                        <div class="sub header">{% trans %}One-time passcode authentication.{% endtrans %}</div>
                    </h2>
                {% endblock %}

                {% block messages %}
                    {{ flask.messages() }}
                {% endblock %}

                {% call fui.render_form(form, hx_boost="false") %}
                    <div class="ui icon message">
                        <i class="shield icon"></i>
                        <div class="content">
                            <div class="header">
                                {% trans %}Open your authenticator application{% endtrans %}
                            </div>
                            {% trans %}
                                Generate a one-time passcode with your authenticator application and fill it in the form below.
                            {% endtrans %}
                        </div>
                    </div>

                    {% block fields %}
                        {{ login_field.render_field(form.otp, class="autofocus") }}
                    {% endblock %}

                    {% block buttons %}
                        <div class="ui left floated stackable buttons">
                            <a type="button" class="ui button" href="{{ url_for('core.auth.login') }}">
                                {{ _("I am not %(username)s", username=g.auth.user_name) }}
                            </a>
                        </div>
                        <div class="ui right floated stackable buttons">
                            <button type="submit" class="ui primary button">{{ _("Verify") }}</button>
                        </div>
                    {% endblock %}
                {% endcall %}
            </div>
        </div>
    </div>
{% endblock %}
