122 lines
4.4 KiB
HTML
122 lines
4.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Connexion | Administration</title>
|
|
<style>
|
|
/* Variables de design (les mêmes que votre projet) */
|
|
:root {
|
|
--background: #0a0a0a;
|
|
--surface-card: #1e1e1e;
|
|
--border: #2e2e2e;
|
|
--gold: #C9A84C;
|
|
--text: #ffffff;
|
|
--muted: #aaaab8;
|
|
--gold-glow: rgba(201, 168, 76, 0.2);
|
|
}
|
|
body {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-height: 100vh;
|
|
background: var(--background);
|
|
font-family: 'DM Sans', sans-serif;
|
|
margin: 0;
|
|
}
|
|
.login-wrap {
|
|
width: 90%;
|
|
max-width: 400px;
|
|
padding: 2.5rem;
|
|
background: var(--surface-card);
|
|
border: 1px solid var(--border);
|
|
border-radius: 16px;
|
|
text-align: center;
|
|
box-shadow: 0 30px 70px rgba(0,0,0,0.9);
|
|
}
|
|
.login-wrap h2 { font-size: 1.8rem; margin-bottom: 2rem; color: var(--text); }
|
|
.login-wrap h2 span { color: var(--gold); }
|
|
.login-wrap input {
|
|
width: 100%;
|
|
padding: 0.9rem;
|
|
margin-bottom: 1rem;
|
|
background: var(--background);
|
|
border: 1px solid var(--border);
|
|
border-radius: 8px;
|
|
color: var(--text);
|
|
text-align: center;
|
|
font-size: 1rem;
|
|
box-sizing: border-box;
|
|
}
|
|
.btn-gold {
|
|
width: 100%;
|
|
padding: 0.9rem;
|
|
background: var(--gold);
|
|
color: #000;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
}
|
|
.btn-gold:hover { box-shadow: 0 0 15px var(--gold-glow); }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="login-wrap">
|
|
<h2>Mon <span>Cinéma</span></h2>
|
|
<div id="login-form-block">
|
|
<input type="password" id="login-pwd" placeholder="Mot de passe" onkeydown="if(event.key==='Enter') doLogin()">
|
|
<button class="btn-gold" onclick="doLogin()">Se connecter</button>
|
|
</div>
|
|
<div id="blank-setup-block" style="display:none;">
|
|
<p style="color: var(--muted); margin-bottom: 1.5rem; font-size: 0.9rem;">Système prêt. Cliquez pour définir votre mot de passe.</p>
|
|
<button class="btn-gold" onclick="doLoginBlank()">Initialiser le compte</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const API_URL = '../api.php';
|
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
try {
|
|
const res = await fetch(`${API_URL}?action=check_security_status`);
|
|
const data = await res.json();
|
|
if (data.is_blank) {
|
|
document.getElementById('login-form-block').style.display = 'none';
|
|
document.getElementById('blank-setup-block').style.display = 'block';
|
|
}
|
|
} catch (e) { console.error("Erreur API", e); }
|
|
});
|
|
|
|
async function doLogin() { await performLogin(document.getElementById('login-pwd').value); }
|
|
async function doLoginBlank() { await performLogin(''); }
|
|
|
|
async function performLogin(pwd) {
|
|
try {
|
|
const res = await fetch(`${API_URL}?action=login`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ password: pwd })
|
|
});
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
localStorage.setItem('token', data.token);
|
|
if (data.blank === true) {
|
|
const newPwd = prompt("Définissez votre mot de passe (min 4 caractères) :");
|
|
if (newPwd && newPwd.length >= 4) {
|
|
await fetch(`${API_URL}?action=setup_admin`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', 'Authorization': data.token },
|
|
body: JSON.stringify({ password: newPwd })
|
|
});
|
|
alert("Configuré !");
|
|
} else return;
|
|
}
|
|
window.location.href = 'dashboard.html';
|
|
} else { alert("Erreur : " + data.error); }
|
|
} catch(e) { alert("Erreur technique"); }
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |