85 lines
2.5 KiB
HTML
85 lines
2.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Личный кабинет</title>
|
|
<link rel="stylesheet" href="css/auth.css">
|
|
<style>
|
|
:root {
|
|
color-scheme: light;
|
|
--bg: #f5f7fb;
|
|
--card: #ffffff;
|
|
--text: #1b1f2a;
|
|
--muted: #6b7280;
|
|
--border: #e5e7eb;
|
|
--accent: #3b82f6;
|
|
--accent-dark: #2563eb;
|
|
}
|
|
* { box-sizing: border-box; }
|
|
body {
|
|
margin: 0;
|
|
font-family: "Segoe UI", Arial, sans-serif;
|
|
background: linear-gradient(135deg, #eef2ff, #f8fafc);
|
|
color: var(--text);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 24px;
|
|
}
|
|
.card {
|
|
width: 100%;
|
|
max-width: 520px;
|
|
background: var(--card);
|
|
border: 1px solid var(--border);
|
|
border-radius: 12px;
|
|
padding: 24px;
|
|
box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
|
|
}
|
|
h2 {
|
|
margin: 0 0 16px;
|
|
font-size: 24px;
|
|
}
|
|
.actions {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="card">
|
|
<div id="user-info"></div>
|
|
<div class="actions">
|
|
<button class="btn-primary" onclick="logout()">Выйти</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Проверка авторизации при загрузке страницы
|
|
async function checkAuth() {
|
|
const response = await fetch('api/check_auth.php', { credentials: 'same-origin' });
|
|
const result = await response.json();
|
|
|
|
if (!result.isLoggedIn) {
|
|
window.location.href = 'login.html';
|
|
} else {
|
|
document.getElementById('user-info').innerHTML = `
|
|
<h2>Добро пожаловать, ${result.user.username}!</h2>
|
|
`;
|
|
}
|
|
}
|
|
|
|
async function logout() {
|
|
await fetch('api/logout.php', {
|
|
method: 'POST',
|
|
credentials: 'same-origin'
|
|
});
|
|
window.location.href = 'login.html';
|
|
}
|
|
|
|
// Проверяем авторизацию
|
|
checkAuth();
|
|
</script>
|
|
</body>
|
|
</html> |