mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-21 00:23:53 -04:00
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.
76 lines
2.3 KiB
HTML
76 lines
2.3 KiB
HTML
{% extends "withoutnav_template.html" %}
|
|
{% from "components/page-header.html" import page_header %}
|
|
{% from "components/button/macro.njk" import govukButton %}
|
|
{% from "components/back-link/macro.njk" import govukBackLink %}
|
|
{% 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 %}
|
|
|
|
{% set page_title = 'Security keys' %}
|
|
{% set credentials = current_user.webauthn_credentials %}
|
|
|
|
{% block extra_javascripts_before_body %}
|
|
{{ webauthn_api_check() }}
|
|
{% endblock %}
|
|
|
|
{% block per_page_title %}
|
|
{{ page_title }}
|
|
{% endblock %}
|
|
|
|
{% block maincolumn_content %}
|
|
{{ page_header(
|
|
page_title,
|
|
back_link=url_for('.user_profile')
|
|
) }}
|
|
|
|
<div class="govuk-grid-row">
|
|
<div class="govuk-grid-column-five-sixths">
|
|
{% if credentials %}
|
|
|
|
{% call mapping_table(
|
|
caption=page_title,
|
|
field_headings=['Security key'],
|
|
field_headings_visible=False,
|
|
caption_visible=False,
|
|
) %}
|
|
{% for credential in credentials %}
|
|
{% call row() %}
|
|
{% call field() %}
|
|
<div class="govuk-body">{{ credential.name }}</div>
|
|
<div class="govuk-body hint">Registered {{ credential.created_at|format_delta }}</div>
|
|
{% endcall %}
|
|
{% endcall %}
|
|
{% endfor %}
|
|
{% endcall %}
|
|
|
|
{% else %}
|
|
|
|
<p class="govuk-body">
|
|
Security keys are an alternative way of signing in to Notify.
|
|
</p>
|
|
|
|
{% endif %}
|
|
|
|
{{ govukErrorMessage({
|
|
"classes": "webauthn__api-missing",
|
|
"text": "Your browser does not support security keys. Try signing in to Notify using a different browser."
|
|
}) }}
|
|
|
|
{{ govukErrorMessage({
|
|
"classes": "webauthn__no-js",
|
|
"text": "JavaScript is not available for this page. Security keys need JavaScript to work."
|
|
}) }}
|
|
|
|
{{ govukButton({
|
|
"element": "button",
|
|
"text": "Register a key",
|
|
"classes": "govuk-button--secondary webauthn__api-required",
|
|
"attributes": {
|
|
"data-module": "register-security-key",
|
|
"data-csrf-token": csrf_token(),
|
|
}
|
|
}) }}
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|