Files
notifications-admin/app/templates/views/user-profile/security-keys.html
Chris Hill-Scott c63313e839 Give WebAuthn illustration a fixed size
The browser uses the `width` and `height` attributes of the image tag to
allocate space on the page for the image.

If these aren’t provided then the browser will assume the image takes up
no space, until it’s downloaded it and had a look at what the file’s
dimensions are. This causes the layout of the page to jump once the
image downloads.

`149 × 150px` is the native size of the image. But we don’t want it to
display at that size, so this commit also adds some extra CSS which
keeps it looking the same, namely:
- the full width of the 1/4 page column on desktop
- the full width of the column minus a `40px` gutter either side on
  mobile (by using `box-sizing: border-box` the `40px` of padding is
  subtracted from the 100% width, rather than added to it)
2021-09-30 14:19:27 +01:00

108 lines
3.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% 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 edit_field, 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 backLink %}
{{ govukBackLink({ "href": url_for('.user_profile') }) }}
{% endblock %}
{% block maincolumn_content %}
{% set webauthn_button %}
{{ 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(),
}
}) }}
{{ 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."
}) }}
{% endset %}
<div class="govuk-grid-row">
{{ govukErrorMessage({
"classes": "banner-dangerous govuk-!-display-none",
"html": (
'Theres a problem with your security key' +
'<p class="govuk-body">Check you have the right key and try again. ' +
'If this does not work, ' +
'<a class="govuk-link govuk-link--no-visited-state" href=' + url_for('main.support') + ">contact us</a>." +
'</p>'
),
"attributes": {
"aria-live": "polite",
"tabindex": '-1'
}
}) }}
{% if credentials %}
<div class="govuk-grid-column-five-sixths">
{{ 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() %}
<div class="govuk-body">{{ credential.name }}</div>
<div class="govuk-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 %}
<div class="govuk-grid-column-one-half">
{{ page_header(page_title) }}
<p class="govuk-body">
Security keys are an alternative way of signing in to Notify,
instead of getting a code in a text message
</p>
<p class="govuk-body">
You can buy any key thats compatible with the WebAuthn
standard.
</p>
{{ webauthn_button }}
</div>
<div class="govuk-grid-column-one-quarter">
<img src="{{ asset_url('images/security-key.svg') }}" alt="" class="webauthn-illustration" width="149" height="150">>
</div>
{% endif %}
</div>
</div>
{% endblock %}