46 lines
1.5 KiB
HTML
46 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ru" data-title="Вход в панель" data-description="Авторизация администратора гостиницы">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="style.css">
|
|
<title>Вход</title>
|
|
</head>
|
|
<body>
|
|
<header></header>
|
|
<main>
|
|
<h1>Вход в систему управления</h1>
|
|
<form id="loginForm">
|
|
<label>Логин</label>
|
|
<input type="text" name="login" required>
|
|
<label>Пароль</label>
|
|
<input type="password" name="password" required>
|
|
<button type="submit">Войти</button>
|
|
<p id="error" style="color: red; display: none;"></p>
|
|
</form>
|
|
</main>
|
|
<script src="nav.js"></script>
|
|
<script src="seo.js"></script>
|
|
<script>
|
|
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const form = e.target;
|
|
const res = await fetch('/api/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
login: form.login.value,
|
|
password: form.password.value
|
|
})
|
|
});
|
|
if (res.ok) {
|
|
window.location.href = '/admin.html';
|
|
} else {
|
|
const err = document.getElementById('error');
|
|
err.textContent = 'Неверный логин или пароль';
|
|
err.style.display = 'block';
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |