| 1 |
{# |
| 2 |
This template receives the following pieces of context in addition to the form: |
| 3 |
On GET: |
| 4 |
available_methods: Value of SECURITY_US_ENABLED_METHODS |
| 5 |
active_methods: Which methods user has already set up |
| 6 |
current_methods_msg: a translated string of already set up methods |
| 7 |
setup_methods: Which methods require a setup (e.g. password doesn't require any setup) |
| 8 |
|
| 9 |
On successful POST: |
| 10 |
available_methods: Value of SECURITY_US_ENABLED_METHODS |
| 11 |
active_methods: Which methods user has already set up |
| 12 |
current_methods_msg: a translated string of already set up methods |
| 13 |
setup_methods: Which methods require a setup (e.g. password doesn't require any setup) |
| 14 |
chosen_method: which identity method was chosen (e.g. sms, authenticator) |
| 15 |
code_sent: Was a code sent? |
| 16 |
state: a signed state token used to validate the code. |
| 17 |
|
| 18 |
If chosen method is 'authenticator' then additionally: |
| 19 |
authr_qrcode: the image source for the qrcode |
| 20 |
authr_key: same key as in qrcode - for possible manual entry |
| 21 |
authr_username: same username as in qrcode |
| 22 |
authr_issuer: same issuer as in qrcode |
| 23 |
#} |
| 24 |
{% set title = title|default(_fsdomain('Setup Unified Sign In')) %} |
| 25 |
{% extends "security/base.html" %} |
| 26 |
{% from "security/_macros.html" import render_field_with_errors, render_field, render_field_errors, render_form_errors, render_csrf %} |
| 27 |
|
| 28 |
{% block content %} |
| 29 |
{% include "security/_messages.html" %} |
| 30 |
<h1>{{ _fsdomain("Setup Unified Sign In") }}</h1> |
| 31 |
<form action="{{ url_for_security('us_setup') }}" method="post" name="us_setup_form"> |
| 32 |
{{ us_setup_form.hidden_tag() }} |
| 33 |
{{ render_form_errors(us_setup_form) }} |
| 34 |
{% if setup_methods %} |
| 35 |
<div class="fs-div"> |
| 36 |
{{ current_methods_msg }} |
| 37 |
</div> |
| 38 |
<h3>{{ us_setup_form.chosen_method.label.text }}</h3> |
| 39 |
<div class="fs-div"> |
| 40 |
{% for subfield in us_setup_form.chosen_method %}{{ render_field_with_errors(subfield) }}{% endfor %} |
| 41 |
{{ render_field_errors(us_setup_form.chosen_method) }} |
| 42 |
</div> |
| 43 |
<div class="fs-div"> |
| 44 |
{% if "sms" in available_methods and "sms" not in active_methods %} |
| 45 |
{{ render_field_with_errors(us_setup_form.phone) }} |
| 46 |
{% endif %} |
| 47 |
</div> |
| 48 |
{% if us_setup_form.delete_method.choices and not state %} |
| 49 |
{# don't show delete if we're trying to validate a setup #} |
| 50 |
<h3>{{ us_setup_form.delete_method.label }}</h3> |
| 51 |
<div class="fs-div"> |
| 52 |
{% for subfield in us_setup_form.delete_method %}{{ render_field_with_errors(subfield) }}{% endfor %} |
| 53 |
{{ render_field_errors(us_setup_form.delete_method) }} |
| 54 |
</div> |
| 55 |
{% endif %} |
| 56 |
<div class="fs-gap">{{ render_field(us_setup_form.submit) }}</div> |
| 57 |
{% if chosen_method == "authenticator" %} |
| 58 |
<hr> |
| 59 |
<div class="fs-center"> |
| 60 |
<div> |
| 61 |
{{ _fsdomain("Open an authenticator app on your device and scan the following QRcode (or enter the code below manually) to start receiving codes:") }} |
| 62 |
</div> |
| 63 |
<div> |
| 64 |
<img alt="{{ _fsdomain('Passwordless QRCode') }}" id="qrcode" src="{{ authr_qrcode }}"> |
| 65 |
{# TODO: add width and heigth attrs #} |
| 66 |
</div> |
| 67 |
<div>{{ authr_key }}</div> |
| 68 |
</div> |
| 69 |
{% endif %} |
| 70 |
{% else %} |
| 71 |
<h3>{{ _fsdomain("No methods have been enabled - nothing to setup") }}</h3> |
| 72 |
{% endif %} |
| 73 |
</form> |
| 74 |
{% if state %} |
| 75 |
{# Completing setup by entering code #} |
| 76 |
<hr class="fs-gap"> |
| 77 |
<div class="fs-important">{{ _fsdomain("Enter code here to complete setup") }}</div> |
| 78 |
<form action="{{ url_for_security('us_setup_validate', token=state) }}" method="post" name="us_setup_validate_form"> |
| 79 |
{# explicitly render csrf_token so we can change the ID so we don't get duplicates #} |
| 80 |
{{ render_csrf(us_setup_validate_form, "code") }} |
| 81 |
{{ render_field_with_errors(us_setup_validate_form.passcode) }} |
| 82 |
<div class="fs-gap">{{ render_field(us_setup_validate_form.submit) }}</div> |
| 83 |
</form> |
| 84 |
{% endif %} |
| 85 |
{% if security.webauthn %} |
| 86 |
<hr class="fs-gap"> |
| 87 |
<h2>WebAuthn</h2> |
| 88 |
<div class="fs-div"> |
| 89 |
{{ _fsdomain("This application supports passkeys.") }} |
| 90 |
<a href="{{ url_for_security('wan_register') }}">{{ _fsdomain("You can set them up here.") }}</a> |
| 91 |
</div> |
| 92 |
{% endif %} |
| 93 |
{% include "security/_menu.html" %} |
| 94 |
{% endblock content %} |