Public directory contains the Kanban SPA with dashboard UI, login page, and styles. Portal directory provides a standalone service entry page with CSS styling.
19 lines
626 B
JavaScript
19 lines
626 B
JavaScript
const form = document.getElementById('loginForm');
|
|
const tokenInput = document.getElementById('tokenInput');
|
|
const loginError = document.getElementById('loginError');
|
|
|
|
form.addEventListener('submit', async (event) => {
|
|
event.preventDefault();
|
|
loginError.textContent = '';
|
|
const response = await fetch('/api/auth/login', {
|
|
method: 'POST',
|
|
headers: { 'content-type': 'application/json' },
|
|
body: JSON.stringify({ token: tokenInput.value })
|
|
});
|
|
if (response.ok) {
|
|
window.location.href = '/';
|
|
return;
|
|
}
|
|
loginError.textContent = response.status === 429 ? '尝试次数过多' : 'Token 无效';
|
|
});
|