Загрузить файлы в «/»

This commit is contained in:
2026-07-02 20:28:27 +00:00
parent 33607bae6e
commit b83e07325d
5 changed files with 915 additions and 0 deletions

23
auth.js Normal file
View File

@@ -0,0 +1,23 @@
document.addEventListener('DOMContentLoaded', () => {
const form = document.getElementById('auth-form');
const errorEl = document.getElementById('auth-error');
const isRegister = document.body.dataset.page === 'register';
form.addEventListener('submit', async (e) => {
e.preventDefault();
errorEl.textContent = '';
const email = document.getElementById('email').value.trim();
const password = document.getElementById('password').value;
const endpoint = isRegister ? '/api/auth/register' : '/api/auth/login';
try {
await API.request(endpoint, {
method: 'POST',
body: JSON.stringify({ email, password }),
});
window.location.href = '/';
} catch (err) {
errorEl.textContent = err.message;
}
});
});