healthchecks_healthchecks/templates/accounts/add_totp.html
Pēteris Caune 18585d163d
Improve double-submit prevention in the TOTP form
Chrome users could submit the form multiple time by entering the TOTP
code and then pressing Enter key, or clicking the onscreen submit
button. This would be less likely on low latency connections (because
auto-submit would complete before the user presses Enter key) but quite
doable on high latency connections.

The fix is to attach an event handler to form's "onsubmit" events.
The handler lets the first event through, and call preventDefault()
on subsequent events. This takes care of:

* programmatic submits by calling form.requestSubmit()
* Enter key in an input field
* click on the onscreen submit button
2025-03-14 10:43:58 +02:00

55 lines
1.5 KiB
HTML

{% extends "base.html" %}
{% load compress static hc_extras %}
{% block content %}
<div class="row">
<form class="col-sm-6 col-sm-offset-3" method="post">
<h1>Set Up Authenticator App</h1>
<p>{% site_name %} supports time-based one-time passwords (TOTP) as a
second authentication factor. To use this method, you will need
an authenticator app on your phone.
</p>
{% csrf_token %}
<div class="spacer"></div>
<p class="add-totp-step">
<strong>Step 1.</strong>
Scan the QR code below using your authentication app, or enter
the secret key manually.
</p>
<p>Secret key: <code class="totp-secret">{{ secret }}</code></p>
<img src="{{ qr_data_uri }}" />
<p class="add-totp-step">
<strong>Step 2.</strong>
Enter the six-digit code from your authenticator app below.
</p>
<div class="form-group {{ form.code.css_classes }}">
<input
type="text"
name="code"
pattern="[0-9]{6}"
title="six-digit code"
placeholder="6-digit number"
class="form-control input-lg" />
{% if form.code.errors %}
<div class="help-block">
{{ form.code.errors|join:"" }}
</div>
{% endif %}
</div>
<div class="form-group text-right">
<input
class="btn btn-primary"
type="submit"
name=""
value="Continue">
</div>
</form>
</div>
{% endblock %}