Files
gia-gve-certificates/views/login.ejs
2026-07-01 09:18:06 +05:00

146 lines
4.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Вход — Справки ГИА/ГВЭ</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #f0f2f5;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.login-box {
background: #fff;
padding: 40px 35px;
border-radius: 8px;
box-shadow: 0 2px 12px rgba(0,0,0,0.1);
width: 360px;
}
.login-box h1 {
text-align: center;
margin-bottom: 6px;
font-size: 20px;
color: #333;
}
.login-box .subtitle {
text-align: center;
color: #888;
font-size: 13px;
margin-bottom: 24px;
}
.form-group {
margin-bottom: 16px;
}
.form-group label {
display: block;
margin-bottom: 4px;
font-weight: 500;
font-size: 14px;
color: #444;
}
.form-group input {
width: 100%;
padding: 10px 12px;
border: 1px solid #d0d0d0;
border-radius: 5px;
font-size: 15px;
outline: none;
transition: border-color 0.2s;
}
.form-group input:focus {
border-color: #0066cc;
}
.btn-login {
width: 100%;
padding: 10px;
background: #0066cc;
color: #fff;
border: none;
border-radius: 5px;
font-size: 15px;
cursor: pointer;
margin-top: 4px;
}
.btn-login:hover { background: #0052a3; }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; }
.error-msg {
color: #c0392b;
font-size: 13px;
text-align: center;
margin-top: 10px;
display: none;
}
.error-msg.show { display: block; }
.school-name {
text-align: center;
font-size: 12px;
color: #aaa;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="login-box">
<h1>Справки ГИА / ГВЭ</h1>
<div class="subtitle">МАОУ СОШ № 25 им. В.Г. Феофанова</div>
<form id="login-form" autocomplete="off">
<div class="form-group">
<label for="login">Логин</label>
<input type="text" id="login" required autocomplete="off">
</div>
<div class="form-group">
<label for="password">Пароль</label>
<input type="password" id="password" required autocomplete="off">
</div>
<button type="submit" class="btn-login">Войти</button>
<div id="error-msg" class="error-msg"></div>
</form>
<div class="school-name">Школа № 25 &copy; 2026</div>
</div>
<script>
document.getElementById('login-form').addEventListener('submit', async (e) => {
e.preventDefault();
const btn = e.target.querySelector('button');
const errMsg = document.getElementById('error-msg');
btn.disabled = true;
btn.textContent = 'Вход...';
errMsg.classList.remove('show');
try {
const res = await fetch('/api/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
login: document.getElementById('login').value,
password: document.getElementById('password').value
})
});
const data = await res.json();
if (res.ok && data.success) {
window.__CSRF_TOKEN = data.csrfToken;
window.location.href = '/';
} else {
errMsg.textContent = data.error || 'Ошибка входа';
errMsg.classList.add('show');
}
} catch (err) {
errMsg.textContent = 'Ошибка соединения с сервером';
errMsg.classList.add('show');
}
btn.disabled = false;
btn.textContent = 'Войти';
});
fetch('/api/user').then(r => {
if (r.ok) window.location.href = '/';
});
</script>
</body>
</html>