Files
dodep-simulator/templates/login.html
T

67 lines
2.4 KiB
HTML

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Вход - CS2 Simulator</title>
<link rel="stylesheet" href="/static/css/style.min.css">
</head>
<body>
{% include "_nav.html" %}
<main class="auth-container">
<div class="auth-card">
<h2>Вход в аккаунт</h2>
<form id="loginForm" class="auth-form">
<div class="form-group">
<label for="username">Имя пользователя</label>
<input type="text" id="username" name="username" required minlength="3">
</div>
<div class="form-group">
<label for="password">Пароль</label>
<input type="password" id="password" name="password" required minlength="4">
</div>
<div id="errorMessage" class="error-message" style="display: none;"></div>
<button type="submit" class="btn btn-primary btn-block">Войти</button>
</form>
<p class="auth-footer">
Нет аккаунта? <a href="/register">Зарегистрируйтесь</a>
</p>
</div>
</main>
<script>
document.getElementById('loginForm').addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData(e.target);
const errorDiv = document.getElementById('errorMessage');
try {
const response = await fetch('/web/api/auth/login', {
method: 'POST',
body: formData
});
const data = await response.json();
if (response.ok && data.success) {
window.location.href = data.redirect;
} else {
errorDiv.textContent = data.error || 'Ошибка входа';
errorDiv.style.display = 'block';
}
} catch (error) {
errorDiv.textContent = 'Ошибка соединения с сервером';
errorDiv.style.display = 'block';
}
});
</script>
<script src="/static/js/safemode.js"></script>
</body>
</html>