Actualiser admin/login.html
This commit is contained in:
+28
-52
@@ -4,31 +4,37 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Connexion | Administration</title>
|
<title>Connexion | Administration</title>
|
||||||
<link rel="stylesheet" href="../css/admin.css">
|
|
||||||
<style>
|
<style>
|
||||||
/* Styles spécifiques à la page de login pour centrer le tout */
|
/* 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 {
|
body {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: var(--background);
|
background: var(--background);
|
||||||
|
font-family: 'DM Sans', sans-serif;
|
||||||
|
margin: 0;
|
||||||
}
|
}
|
||||||
.login-wrap {
|
.login-wrap {
|
||||||
width: 100%;
|
width: 90%;
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
padding: 2.5rem;
|
padding: 2.5rem;
|
||||||
background: var(--surface-card);
|
background: var(--surface-card);
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
box-shadow: var(--shadow-overlay);
|
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 { font-size: 1.8rem; margin-bottom: 2rem; color: var(--text); }
|
||||||
.login-wrap h2 span { color: var(--gold); }
|
.login-wrap h2 span { color: var(--gold); }
|
||||||
.login-wrap input {
|
.login-wrap input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -40,73 +46,51 @@
|
|||||||
color: var(--text);
|
color: var(--text);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
box-sizing: border-box;
|
||||||
.login-wrap input:focus {
|
|
||||||
border-color: var(--gold);
|
|
||||||
outline: none;
|
|
||||||
}
|
}
|
||||||
.btn-gold {
|
.btn-gold {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.9rem;
|
padding: 0.9rem;
|
||||||
background: var(--gold);
|
background: var(--gold);
|
||||||
color: var(--background);
|
color: #000;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
}
|
}
|
||||||
.btn-gold:hover {
|
.btn-gold:hover { box-shadow: 0 0 15px var(--gold-glow); }
|
||||||
box-shadow: 0 0 15px var(--gold-glow);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="login-wrap">
|
<div class="login-wrap">
|
||||||
<h2>Mon <span>Cinéma</span></h2>
|
<h2>Mon <span>Cinéma</span></h2>
|
||||||
|
|
||||||
<div id="login-form-block">
|
<div id="login-form-block">
|
||||||
<input type="password" id="login-pwd" placeholder="Mot de passe" onkeydown="if(event.key==='Enter') doLogin()">
|
<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>
|
<button class="btn-gold" onclick="doLogin()">Se connecter</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="blank-setup-block" style="display:none;">
|
<div id="blank-setup-block" style="display:none;">
|
||||||
<p style="color: var(--muted); margin-bottom: 1.5rem; font-size: 0.9rem;">
|
<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>
|
||||||
Système initialisé. Cliquez pour définir votre mot de passe administrateur.
|
|
||||||
</p>
|
|
||||||
<button class="btn-gold" onclick="doLoginBlank()">Initialiser le compte</button>
|
<button class="btn-gold" onclick="doLoginBlank()">Initialiser le compte</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const API_URL = '../api.php';
|
const API_URL = '../api.php';
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
const formBlock = document.getElementById('login-form-block');
|
|
||||||
const blankBlock = document.getElementById('blank-setup-block');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_URL}?action=check_security_status`);
|
const res = await fetch(`${API_URL}?action=check_security_status`);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
|
||||||
if (data.is_blank) {
|
if (data.is_blank) {
|
||||||
formBlock.style.display = 'none';
|
document.getElementById('login-form-block').style.display = 'none';
|
||||||
blankBlock.style.display = 'block';
|
document.getElementById('blank-setup-block').style.display = 'block';
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) { console.error("Erreur API", e); }
|
||||||
console.error("Erreur d'initialisation", e);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function doLogin() {
|
async function doLogin() { await performLogin(document.getElementById('login-pwd').value); }
|
||||||
const pwd = document.getElementById('login-pwd').value;
|
async function doLoginBlank() { await performLogin(''); }
|
||||||
await performLogin(pwd);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function doLoginBlank() {
|
|
||||||
await performLogin('');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function performLogin(pwd) {
|
async function performLogin(pwd) {
|
||||||
try {
|
try {
|
||||||
@@ -116,7 +100,6 @@
|
|||||||
body: JSON.stringify({ password: pwd })
|
body: JSON.stringify({ password: pwd })
|
||||||
});
|
});
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
localStorage.setItem('token', data.token);
|
localStorage.setItem('token', data.token);
|
||||||
if (data.blank === true) {
|
if (data.blank === true) {
|
||||||
@@ -127,19 +110,12 @@
|
|||||||
headers: { 'Content-Type': 'application/json', 'Authorization': data.token },
|
headers: { 'Content-Type': 'application/json', 'Authorization': data.token },
|
||||||
body: JSON.stringify({ password: newPwd })
|
body: JSON.stringify({ password: newPwd })
|
||||||
});
|
});
|
||||||
alert("Mot de passe configuré ! Redirection...");
|
alert("Configuré !");
|
||||||
} else {
|
} else return;
|
||||||
alert("Initialisation annulée.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
window.location.href = 'dashboard.html';
|
window.location.href = 'dashboard.html';
|
||||||
} else {
|
} else { alert("Erreur : " + data.error); }
|
||||||
alert("Erreur : " + (data.error || "Mot de passe incorrect"));
|
} catch(e) { alert("Erreur technique"); }
|
||||||
}
|
|
||||||
} catch(e) {
|
|
||||||
alert("Erreur technique : " + e.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user