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 %}