Debian Codegraph @

flask_security/templates/security/wan_signin.html

raw
1 {#
2 This template receives the following pieces of context in addition to the form:
3 #}
4 {% set title = title|default(_fsdomain("Sign In With A Passkey")) %}
5 {% extends "security/base.html" %}
6 {% from "security/_macros.html" import render_field_with_errors, render_field, render_field_errors, render_form_errors, prop_next, script_nonce %}
7
8 {% block head_scripts %}
9 {{ super() }}
10 <script {{ script_nonce() }} src="{{ url_for('.static', filename='js/webauthn.js') }}"></script>
11 <script {{ script_nonce() }} src="{{ url_for('.static', filename='js/base64.js') }}"></script>
12 {% endblock head_scripts %}
13
14 {% block content %}
15 {% include "security/_messages.html" %}
16 {% if not is_secondary %}
17 <h1>{{ _fsdomain("Sign In With a Passkey") }}</h1>
18 {% else %}
19 <h1>{{ _fsdomain("Use a Passkey as a Second Factor") }}</h1>
20 {% endif %}
21 {% if not credential_options %}
22 <form action="{{ url_for_security('wan_signin') }}{{ prop_next() }}" method="post" name="wan_signin_form" id="wan-signin-form">
23 {{ wan_signin_form.hidden_tag() }}
24 {{ render_form_errors(wan_signin_form) }}
25 {% if not is_secondary %}
26 {{ render_field_with_errors(wan_signin_form.identity) }}
27 {{ render_field_with_errors(wan_signin_form.remember) }}
28 {% endif %}
29 {{ render_field_errors(wan_signin_form.credential) }}
30 {{ render_field_errors(wan_signin_form.csrf_token) }}
31 {{ render_field(wan_signin_form.submit) }}
32 </form>
33 {% else %}
34 <form action="{{ url_for_security('wan_signin_response', token=wan_state) }}{{ prop_next() }}" method="post" name="wan_signin_response_form" id="wan-signin-response-form">
35 {{ wan_signin_response_form.hidden_tag() }}
36 {{ render_field_errors(wan_signin_form.remember) }}
37 {# the following is important even though it is hidden - some browsers
38 require an input focus field (such as Safari)
39 #}
40 {{ render_field(wan_signin_response_form.credential) }}
41 <div id="wan-errors"></div>
42 </form>
43 <script {{ script_nonce() }} type="text/javascript">
44 handleSignin('{{ credential_options|safe }}')
45 .then((result) => {
46 if (result.error_msg) {
47 const error_element = document.getElementById("wan-errors");
48 error_element.innerHTML = `<em>${result.error_msg}</em>`;
49 } else {
50 document.getElementById("credential").value = result.credential;
51 {# We auto-submit this form - there is a Submit button on the
52 form we could use - but there really isn't any reason to force the
53 user to click yet another button
54 #}
55 document.forms["wan-signin-response-form"].submit();
56 }
57 });
58 </script>
59 {% endif %}
60 {% endblock content %}