{# This template receives the following pieces of context in addition to the form: On GET: available_methods: Value of SECURITY_US_ENABLED_METHODS active_methods: Which methods user has already set up current_methods_msg: a translated string of already set up methods setup_methods: Which methods require a setup (e.g. password doesn't require any setup) On successful POST: available_methods: Value of SECURITY_US_ENABLED_METHODS active_methods: Which methods user has already set up current_methods_msg: a translated string of already set up methods setup_methods: Which methods require a setup (e.g. password doesn't require any setup) chosen_method: which identity method was chosen (e.g. sms, authenticator) code_sent: Was a code sent? state: a signed state token used to validate the code. If chosen method is 'authenticator' then additionally: authr_qrcode: the image source for the qrcode authr_key: same key as in qrcode - for possible manual entry authr_username: same username as in qrcode authr_issuer: same issuer as in qrcode #} {% extends "security/base.html" %} {% from "security/_macros.html" import render_field_with_errors, render_field, render_field_errors, render_form_errors %} {% block content %} {% include "security/_messages.html" %}

{{ _fsdomain("Setup Unified Sign In") }}

{{ us_setup_form.hidden_tag() }} {{ render_form_errors(us_setup_form) }} {% if setup_methods %}
{{ current_methods_msg }}

{{ us_setup_form.chosen_method.label }}

{% for subfield in us_setup_form.chosen_method %}{{ render_field_with_errors(subfield) }}{% endfor %} {{ render_field_errors(us_setup_form.chosen_method) }}
{% if "sms" in available_methods and "sms" not in active_methods %} {{ render_field_with_errors(us_setup_form.phone) }} {% endif %}
{% if us_setup_form.delete_method.choices and not state %} {# don't show delete if we're trying to validate a setup #}

{{ us_setup_form.delete_method.label }}

{% for subfield in us_setup_form.delete_method %}{{ render_field_with_errors(subfield) }}{% endfor %} {{ render_field_errors(us_setup_form.delete_method) }}
{% endif %}
{{ render_field(us_setup_form.submit) }}
{% if chosen_method == "authenticator" %}
{{ _fsdomain("Open an authenticator app on your device and scan the following QRcode (or enter the code below manually) to start receiving codes:") }}
{{ _fsdomain('Passwordless QRCode') }} {# TODO: add width and heigth attrs #}
{{ authr_key }}
{% endif %} {% else %}

{{ _fsdomain("No methods have been enabled - nothing to setup") }}

{% endif %}
{% if state %} {# Completing setup by entering code #}
{{ _fsdomain("Enter code here to complete setup") }}
{{ us_setup_validate_form.hidden_tag() }} {{ render_field_with_errors(us_setup_validate_form.passcode) }}
{{ render_field(us_setup_validate_form.submit) }}
{% endif %} {% if security.webauthn %}

WebAuthn

{{ _fsdomain("This application supports WebAuthn security keys.") }} {{ _fsdomain("You can set them up here.") }}
{% endif %} {% include "security/_menu.html" %} {% endblock content %}