Only check for WebAuthn where it's used

This scopes the check for WebAuthn API to the page where we need
it, which will slightly reduce load times for other pages. Since
we want this script to execute ASAP, I've added a new block for
extra JS to run at the start of the body.
This commit is contained in:
Ben Thorner
2021-05-18 13:01:45 +01:00
parent c09f0f0e06
commit 4575ad0fcd
2 changed files with 6 additions and 3 deletions
+1 -3
View File
@@ -1,7 +1,6 @@
{% extends "template.njk" %} {% extends "template.njk" %}
{% from "components/banner.html" import banner %} {% from "components/banner.html" import banner %}
{% from "components/cookie-banner.html" import cookie_banner %} {% from "components/cookie-banner.html" import cookie_banner %}
{% from "components/webauthn-api-check.html" import webauthn_api_check %}
{% block headIcons %} {% block headIcons %}
<link rel="shortcut icon" sizes="16x16 32x32 48x48" href="{{ asset_url('images/favicon.ico') }}" type="image/x-icon" /> <link rel="shortcut icon" sizes="16x16 32x32 48x48" href="{{ asset_url('images/favicon.ico') }}" type="image/x-icon" />
@@ -39,8 +38,7 @@
{% endblock %} {% endblock %}
{% block bodyStart %} {% block bodyStart %}
{% block webauthn_api %} {% block extra_javascripts_before_body %}
{{ webauthn_api_check() }}
{% endblock %} {% endblock %}
{% block cookie_message %} {% block cookie_message %}
@@ -3,11 +3,16 @@
{% from "components/button/macro.njk" import govukButton %} {% from "components/button/macro.njk" import govukButton %}
{% from "components/back-link/macro.njk" import govukBackLink %} {% from "components/back-link/macro.njk" import govukBackLink %}
{% from "components/table.html" import mapping_table, row, field, row_heading %} {% from "components/table.html" import mapping_table, row, field, row_heading %}
{% from "components/webauthn-api-check.html" import webauthn_api_check %}
{% from "vendor/govuk-frontend/components/error-message/macro.njk" import govukErrorMessage %} {% from "vendor/govuk-frontend/components/error-message/macro.njk" import govukErrorMessage %}
{% set page_title = 'Security keys' %} {% set page_title = 'Security keys' %}
{% set credentials = current_user.webauthn_credentials %} {% set credentials = current_user.webauthn_credentials %}
{% block extra_javascripts_before_body %}
{{ webauthn_api_check() }}
{% endblock %}
{% block per_page_title %} {% block per_page_title %}
{{ page_title }} {{ page_title }}
{% endblock %} {% endblock %}