mirror of
https://github.com/zitadel/zitadel.git
synced 2025-05-06 08:46:47 +00:00

# Which Problems Are Solved When registering passkeys or u2f methods as second factor, some users pressed the "Enter" key, rather than clicking the submit button. This method has bypassed the execution of the device registration and encoding scripts, resulting in the form being submitted without the necessary encoded values. # How the Problems Are Solved This PR ensures that device registration is always executed and the required information are submitted in the form regardless of pressing "Enter" or clicking the button. # Additional Changes None # Additional Context - closes #6592 - closes #2910
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
function checkWebauthnSupported(func, optionalClickId) {
|
|
let support = document.getElementsByClassName("wa-support");
|
|
let noSupport = document.getElementsByClassName("wa-no-support");
|
|
if (!window.PublicKeyCredential) {
|
|
for (let item of noSupport) {
|
|
item.classList.remove("hidden");
|
|
}
|
|
for (let item of support) {
|
|
item.classList.add("hidden");
|
|
}
|
|
return;
|
|
}
|
|
|
|
// if id is provided add click event only, otherwise call the function directly
|
|
if (optionalClickId) {
|
|
document.getElementById(optionalClickId).addEventListener("click", func);
|
|
} else {
|
|
func();
|
|
}
|
|
}
|
|
|
|
function webauthnError(error) {
|
|
let err = document.getElementById("wa-error");
|
|
let causeElement = err.getElementsByClassName("cause")[0];
|
|
|
|
if (error.message) {
|
|
causeElement.innerText = error.message;
|
|
} else if (error.value) {
|
|
causeElement.innerText = error.value;
|
|
} else {
|
|
console.error("Unknown error:", error);
|
|
causeElement.innerText = "An unknown error occurred.";
|
|
}
|
|
|
|
err.classList.remove("hidden");
|
|
}
|
|
|
|
function bufferDecode(value, name) {
|
|
return coerceToArrayBuffer(value, name);
|
|
}
|
|
|
|
function bufferEncode(value, name) {
|
|
return coerceToBase64Url(value, name);
|
|
}
|