webauthn登录逻辑调整

This commit is contained in:
2022-08-11 10:43:33 +08:00
parent cc57e4bb18
commit 6632d8cea1
6 changed files with 64 additions and 45 deletions

View File

@ -13,13 +13,16 @@ const webauthn_login = useLogin({
window.webauthn_register = webauthn_register;
window.webauthn_login = webauthn_login;
(function() {
const loginForm = window.document.getElementById("webauthn_login_form");
console.log(loginForm)
if (loginForm) {
loginForm.addEventListener("submit", function (e) {
const button = window.document.getElementById("do_webauthn_login");
if (button) {
button.addEventListener("click", function (e) {
const loginForm = window.document.getElementById("webauthn_login_form");
if (!loginForm) return;
e.preventDefault();
const formData = new FormData(loginForm)
webauthn_login(formData)
webauthn_login({
username: formData.get("username")
})
.then(() => {
// 成功登录
window.location.href = "/"