Files
notifications-admin/app/templates/views/user-profile/security-keys.html

108 lines
3.4 KiB
HTML
Raw Normal View History

{% extends "base.html" %}
{% from "components/page-header.html" import page_header %}
2023-08-30 11:07:38 -04:00
{% from "components/components/button/macro.njk" import usaButton %}
{% from "components/components/back-link/macro.njk" import usaBackLink %}
{% from "components/table.html" import edit_field, mapping_table, row, field, row_heading %}
{% from "components/webauthn-api-check.html" import webauthn_api_check %}
{% from "components/components/error-message/macro.njk" import usaErrorMessage %}
{% 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 backLink %}
2023-08-30 11:07:38 -04:00
{{ usaBackLink({ "href": url_for('.user_profile') }) }}
{% endblock %}
{% block maincolumn_content %}
{% set webauthn_button %}
2023-08-30 11:07:38 -04:00
{{ usaButton({
"element": "button",
"text": "Register a key",
"classes": "govuk-button--secondary webauthn__api-required",
"attributes": {
"data-module": "register-security-key",
"data-csrf-token": csrf_token(),
}
}) }}
{{ usaErrorMessage({
"classes": "webauthn__api-missing",
"text": "Your browser does not support security keys. Try signing in to Notify using a different browser."
}) }}
{{ usaErrorMessage({
"classes": "webauthn__no-js",
"text": "JavaScript is not available for this page. Security keys need JavaScript to work."
}) }}
{% endset %}
2023-08-23 16:18:25 -04:00
<div class="grid-row">
{{ usaErrorMessage({
2023-08-25 10:40:56 -04:00
"classes": "banner-dangerous display-none",
"html": (
'Theres a problem with your security key' +
'<p>Check you have the right key and try again. ' +
'If this does not work, ' +
'<a class="usa-link" href=' + url_for('main.support') + ">contact us</a>." +
'</p>'
),
"attributes": {
"aria-live": "polite",
"tabindex": '-1'
}
}) }}
{% if credentials %}
2023-08-23 16:18:25 -04:00
<div class="grid-col-10">
2021-05-28 16:19:17 +01:00
{{ page_header(page_title) }}
<div class="body-copy-table">
{% call mapping_table(
caption=page_title,
field_headings=['Security key details', 'Action'],
field_headings_visible=False,
caption_visible=False,
) %}
{% for credential in credentials %}
{% call row() %}
{% call field() %}
2023-08-25 11:49:13 -04:00
<div class="usa-body">{{ credential.name }}</div>
<div class="usa-body hint">Registered {{ credential.created_at|format_delta }}</div>
{% endcall %}
{{ edit_field('Manage', url_for('.user_profile_manage_security_key', key_id=credential.id)) }}
{% endcall %}
{% endfor %}
{% endcall %}
</div>
{{ webauthn_button }}
</div>
{% else %}
2023-08-23 16:18:25 -04:00
<div class="grid-col-6">
{{ page_header(page_title) }}
<p>
Security keys are an alternative way of signing in to Notify,
instead of getting a code in a text message
</p>
<p>
You can buy any key thats compatible with the WebAuthn
standard.
</p>
{{ webauthn_button }}
</div>
2023-08-23 16:18:25 -04:00
<div class="grid-col-3">
<img src="{{ asset_url('images/security-key.svg') }}" alt="" class="webauthn-illustration" width="149" height="150">
</div>
2021-05-28 13:52:05 +01:00
{% endif %}
</div>
</div>
{% endblock %}