{% extends 'base.html' %} {# Two-factor auth can be in three states: mfa_init: The user has not setup any two-factor methods or recovery codes mfa_setup: The user has setup recovery codes but no two-factor methods. Two-factor authentication is still disabled. mfa_enabled: The user has setup at least one two-factor method. Two-factor authentication is enabled. #} {% set mfa_enabled = request.user.mfa_enabled %} {% set mfa_init = not request.user.mfa_recovery_codes and not mfa_enabled %} {% set mfa_setup = request.user.mfa_recovery_codes and not mfa_enabled %} {% block body %}

{% if mfa_enabled %} {{ _("Two-factor authentication is currently enabled.")|safe }} {% else %} {{ _("Two-factor authentication is currently disabled.")|safe }} {% endif %} {% if mfa_init %} {{_("You need to generate recovery codes and setup at least one authentication method to enable two-factor authentication.")}} {% elif mfa_setup %} {{_("You need to setup at least one authentication method to enable two-factor authentication.")}} {% endif %}

{% if mfa_setup or mfa_enabled %}
{% if mfa_enabled %}
{% else %}
{% endif %}
{% endif %}

{{_("Recovery Codes")}}

{{_("Recovery codes allow you to login and setup new two-factor methods when you lost your registered second factor.")}}

{% if mfa_init %}{% endif %} {{_("You need to setup recovery codes before you can setup up authenticator apps or U2F/FIDO2 devices.")}} {% if mfa_init %}{% endif %} {{_("Each code can only be used once.")}}

{% if mfa_init %} {% else %} {% endif %}
{% if request.user.mfa_recovery_codes %}

{{ request.user.mfa_recovery_codes|length }} recovery codes remain

{% elif not request.user.mfa_recovery_codes and mfa_enabled %}

{{_("You have no remaining recovery codes.")}}

{% endif %}

{{_("Authenticator Apps (TOTP)")}}

{{_("Use an authenticator application on your mobile device as a second factor.")}}

{{_("The authenticator app generates a 6-digit one-time code each time you login. Compatible apps are freely available for most phones.")}}

{% for method in request.user.mfa_totp_methods %} {% endfor %} {% if not request.user.mfa_totp_methods %} {% endif %}
{{_("Name")}} {{_("Registered On")}}
{{ method.name }} {{ method.created|dateformat }} {{_("Delete")}}
{{_("No authenticator apps registered yet")}}

{{_("U2F and FIDO2 Devices")}}

{{_("Use an U2F or FIDO2 compatible hardware security key as a second factor.")}}

{{_("U2F and FIDO2 devices are not supported by all browsers and can be particularly difficult to use on mobile devices. It is strongly recommended to also setup an authenticator app to be able to login on all browsers.")}}

{% if not webauthn_supported %} {% endif %}
{% for method in request.user.mfa_webauthn_methods %} {% endfor %} {% if not request.user.mfa_webauthn_methods %} {% endif %}
{{_("Name")}} {{_("Registered On")}}
{{ method.name }} {{ method.created|dateformat }} {{_("Delete")}}
{{_("No U2F/FIDO2 devices registered yet")}}
{% if webauthn_supported %} {% endif %} {% endblock %}