create: admin.html, admin.js, help.html, index.html, info.html, info.js, login.html, main.js, style.css, auth.js, package.json, server.js, sqllite.js
This commit is contained in:
committed by
GitVerse
parent
458b1fa927
commit
3fbf7311d8
53
public/login.html
Normal file
53
public/login.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Вход в админку</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<style>
|
||||
.login-container {
|
||||
max-width: 400px;
|
||||
margin: 4rem auto;
|
||||
background: white;
|
||||
padding: 2rem;
|
||||
border-radius: 1.5rem;
|
||||
box-shadow: 0 8px 20px rgba(0,0,0,0.1);
|
||||
}
|
||||
.error { color: #b91c1c; margin-top: 1rem; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-container">
|
||||
<h2>Авторизация администратора</h2>
|
||||
<form id="loginForm">
|
||||
<label>Логин: <input type="text" id="username" required></label>
|
||||
<label>Пароль: <input type="password" id="password" required></label>
|
||||
<button type="submit">Войти</button>
|
||||
<div id="errorMsg" class="error"></div>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const username = document.getElementById('username').value;
|
||||
const password = document.getElementById('password').value;
|
||||
const errorDiv = document.getElementById('errorMsg');
|
||||
try {
|
||||
const res = await fetch('/api/auth', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ username, password })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok && data.success) {
|
||||
window.location.href = '/admin';
|
||||
} else {
|
||||
errorDiv.innerText = data.message || 'Ошибка входа';
|
||||
}
|
||||
} catch (err) {
|
||||
errorDiv.innerText = 'Ошибка соединения';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user