Disable "Start enrollment" button while processing credentials

This commit is contained in:
Pierre HUBERT 2022-04-21 19:31:38 +02:00
parent 0f17a8a35c
commit f09a62f8df

View File

@ -15,7 +15,7 @@
</div> </div>
<input type="button" class="btn btn-primary" value="Start enrollment" onclick="startEnrollment()" <input type="button" class="btn btn-primary" value="Start enrollment" onclick="startEnrollment()"
style="margin-top: 20px;"/> style="margin-top: 20px;" id="submitButton" />
<script src="/assets/js/base64_lib.js"></script> <script src="/assets/js/base64_lib.js"></script>
<script> <script>
@ -30,8 +30,10 @@
REGISTRATION_CHALLENGE.publicKey.user.id REGISTRATION_CHALLENGE.publicKey.user.id
); );
const submitButton = document.getElementById("submitButton");
async function startEnrollment() { async function startEnrollment() {
submitButton.disabled = true;
try { try {
const factorNameInput = document.getElementById("inputKeyName"); const factorNameInput = document.getElementById("inputKeyName");
factorNameInput.classList.remove("is-invalid"); factorNameInput.classList.remove("is-invalid");
@ -77,6 +79,8 @@
} catch(e) { } catch(e) {
console.error(e); console.error(e);
alert("Failed enrollment, please try again!"); alert("Failed enrollment, please try again!");
} finally {
submitButton.disabled = false;
} }
} }
</script> </script>