2020-01-15 18:27:12 +08:00
|
|
|
import { getWebauthnCredential } from "discourse/lib/webauthn";
|
|
|
|
|
2020-03-11 21:43:55 +08:00
|
|
|
const security = document.getElementById("submit-security-key");
|
|
|
|
if (security) {
|
|
|
|
security.onclick = function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
getWebauthnCredential(
|
|
|
|
document.getElementById("security-key-challenge").value,
|
|
|
|
document
|
|
|
|
.getElementById("security-key-allowed-credential-ids")
|
|
|
|
.value.split(","),
|
|
|
|
credentialData => {
|
|
|
|
document.getElementById(
|
|
|
|
"security-key-credential"
|
|
|
|
).value = JSON.stringify(credentialData);
|
2020-01-15 18:27:12 +08:00
|
|
|
|
2020-03-11 21:43:55 +08:00
|
|
|
$(e.target)
|
|
|
|
.parents("form")
|
|
|
|
.submit();
|
|
|
|
},
|
|
|
|
errorMessage => {
|
|
|
|
document.getElementById("security-key-error").innerText = errorMessage;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|