import Head from 'next/head'; import { useRouter } from 'next/router'; import { useState, type FormEvent } from 'react'; // Keep this page independent of server-only authentication modules. export default function Login() { const router = useRouter(); const [code,setCode] = useState(''); const [error,setError] = useState(''); const [busy,setBusy] = useState(false); async function submit(event: FormEvent) { event.preventDefault(); if (busy) return; setBusy(true); setError(''); try { const response = await fetch('/api/auth/login',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({code})}); const data = await response.json(); if (!response.ok) { setError(data.error || '登录没有完成'); setCode(''); return; } const next = router.query.next; window.location.assign(typeof next === 'string' && next.startsWith('/') && !next.startsWith('//') && !/[\\\r\n]/.test(next) && !next.startsWith('/login') ? next : '/'); } catch { setError('暂时无法连接,请稍后重试'); } finally { setBusy(false); } } return <>动态码登录 · 啡跃 Endoleap
啡跃 Endoleap

输入动态码

打开验证器,输入当前的 6 位动态码。

setCode(e.target.value.replace(/\D/g,''))} placeholder="000000" aria-describedby="auth-error"/>

尚未绑定验证器?请联系管理员。

; }