security update
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user