You've already forked lubo_comment_query
webauthn登录逻辑调整
This commit is contained in:
@ -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 = "/"
|
||||
|
@ -4,10 +4,11 @@
|
||||
<title>登录</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link href="{{ mix('/css/app.css') }}" rel="stylesheet"/>
|
||||
<script src="{{ mix('/js/manifest.js') }}" rel="script"></script>
|
||||
</head>
|
||||
<body>
|
||||
@include("common.header")
|
||||
<form class="w-full lg:w-1/2 border-2 mx-auto my-2" action="" method="post" enctype="multipart/form-data">
|
||||
<form class="w-full lg:w-1/2 border-2 mx-auto my-2" id="webauthn_login_form" action="" method="post" enctype="multipart/form-data">
|
||||
<div class="block text-lg font-bold ml-4 mt-2">登录</div>
|
||||
@csrf
|
||||
<label class="block my-2">
|
||||
@ -25,11 +26,12 @@
|
||||
@include("common.form_error")
|
||||
<div class="block my-2 text-center">
|
||||
<input class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" type="submit" value="登录">
|
||||
<a class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" href="{{ url(route("login.webauthn")) }}">
|
||||
<a class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" id="do_webauthn_login" href="javascript: void 0">
|
||||
免输入登录<sup class="text-xs bg-yellow-600 text-white">Alpha</sup>
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
@include("common.footer")
|
||||
</body>
|
||||
<script src="{{ mix('/js/webauthn.js') }}" rel="script"></script>
|
||||
</html>
|
||||
|
@ -1,26 +0,0 @@
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>WebAuthn登录</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link href="{{ mix('/css/app.css') }}" rel="stylesheet"/>
|
||||
<script src="{{ mix('/js/manifest.js') }}" rel="script"></script>
|
||||
</head>
|
||||
<body>
|
||||
@include("common.header")
|
||||
<form class="w-full lg:w-1/2 border-2 mx-auto my-2" id="webauthn_login_form" action="javascript:void 0" method="post" enctype="multipart/form-data">
|
||||
<div class="block text-lg font-bold ml-4 mt-2">登录</div>
|
||||
@csrf
|
||||
<label class="block my-2">
|
||||
用户名
|
||||
<input class="form-input border-0 border-b-2 w-full" type="text" name="username" value="{{ old("username") }}" placeholder="用户名或邮箱">
|
||||
</label>
|
||||
@include("common.form_error")
|
||||
<div class="block my-2 text-center">
|
||||
<input class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" type="submit" value="免输入登录">
|
||||
</div>
|
||||
</form>
|
||||
@include("common.footer")
|
||||
</body>
|
||||
<script src="{{ mix('/js/webauthn.js') }}" rel="script"></script>
|
||||
</html>
|
Reference in New Issue
Block a user