Authorizing with WebAuthn
Let's first change index.html
in the login form
<section hidden id="login_section_webauthn">
<a href="#" class="navlink" onclick="Auth.webAuthnLogin(); event.preventDefault">Log in with your Authenticator</a>
</section>
And finally on Auth.js
we add:
webAuthnLogin: async (optional) => {
const email = document.getElementById("login_email").value;
const options = await API.webAuthn.loginOptions(email);
const loginRes = await SimpleWebAuthnBrowser.startAuthentication(options);
const verificationRes = await API.webAuthn.loginVerification(email, loginRes);
if (verificationRes) {
Auth.postLogin(verificationRes, verificationRes.user);
} else {
alert(verificationRes.message)
}
}