From 597846f657b5f8ab6b19be4b9a72ba3ddc6c8f0e Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 28 May 2021 13:55:31 +0100 Subject: [PATCH] Refactor error button and error messages into variable --- .../views/user-profile/security-keys.html | 58 ++++++++----------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/app/templates/views/user-profile/security-keys.html b/app/templates/views/user-profile/security-keys.html index fc249b8f1..2025754d8 100644 --- a/app/templates/views/user-profile/security-keys.html +++ b/app/templates/views/user-profile/security-keys.html @@ -19,6 +19,28 @@ {% 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 %} + {{ govukBackLink({ "href": url_for('.user_profile') }) }}
@@ -46,17 +68,7 @@ {% endfor %} {% endcall %}
- - {{ 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(), - } - }) }} - + {{ webauthn_button }} {% else %}
@@ -69,34 +81,12 @@ You can buy any key that’s compatible with the WebAuthn standard.

- {{ 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(), - } - }) }} + {{ webauthn_button }}
{% 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." - }) }} - -
{% endblock %}