security update

This commit is contained in:
2026-01-19 08:57:58 +03:00
parent 55b3d5f088
commit 5c084c6aaa
8 changed files with 182 additions and 49 deletions

View File

@@ -3,11 +3,15 @@ async function sendRequest(url, data) {
try {
const response = await fetch(url, {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data)
});
if (!response.ok) {
return { success: false, message: 'Ошибка сервера' };
}
return await response.json();
} catch (error) {
console.error('Ошибка:', error);
@@ -45,10 +49,6 @@ if (document.getElementById('loginForm')) {
const result = await sendRequest('api/login.php', data);
if (result.success) {
// Сохраняем данные пользователя в localStorage
localStorage.setItem('user', JSON.stringify(result.user));
localStorage.setItem('isLoggedIn', 'true');
alert(result.message);
window.location.href = 'index.html';
} else {