免输入登录功能提交

This commit is contained in:
2022-08-08 10:25:55 +08:00
parent eff07c4f72
commit 6e4faf0865
5 changed files with 57 additions and 4 deletions

View File

@ -10,5 +10,25 @@ const webauthn_login = useLogin({
optionsUrl: "/login/webauthn/options",
})
window.webauthn_register = webauthn_register
window.webauthn_login = webauthn_login
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) {
e.preventDefault();
const formData = new FormData(loginForm)
webauthn_login(formData)
.then(() => {
// 成功登录
window.location.href = "/"
})
.catch((err) => {
console.error(err)
alert("登录失败");
})
return false;
})
}
})()