Files
xamxam/public/admin/login.php

60 lines
2.0 KiB
PHP
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.
<?php
require_once __DIR__ . '/../../config/bootstrap.php';
require_once __DIR__ . '/../../src/AdminAuth.php';
if (!defined('ADMIN_PASSWORD_HASH')) {
header('Location: /admin/');
exit;
}
if (AdminAuth::isAuthenticated()) {
header('Location: /admin/');
exit;
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$password = $_POST['password'] ?? '';
if (AdminAuth::login($password)) {
header('Location: /admin/');
exit;
}
$error = 'Mot de passe incorrect.';
}
$pageTitle = 'Connexion';
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Connexion Posterg Admin</title>
<link rel="icon" type="image/svg+xml" href="/assets/admin_favicon.svg">
<link rel="stylesheet" href="/assets/modern-normalize.min.css">
<link rel="stylesheet" href="/assets/admin.css">
</head>
<body class="admin-body">
<nav class="admin-nav">
<span class="admin-nav__logo">Posterg</span>
</nav>
<div class="admin-login-wrap">
<div class="admin-login-box">
<h2>Administration</h2>
<?php if ($error): ?>
<div class="admin-alert admin-alert--error">⚠ <?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<form method="post" action="/admin/login.php" class="admin-form">
<div class="admin-form-row" style="grid-template-columns:1fr;border:none;padding:.4rem 0;">
<label class="admin-label" style="font-size:.82rem;color:var(--admin-text-muted);" for="password">Mot de passe</label>
<input class="admin-input" type="password" id="password" name="password" required autofocus>
</div>
<div class="admin-submit-wrap" style="margin-top:1rem;padding-top:.5rem;">
<button type="submit" class="admin-btn" style="width:100%;">Se connecter</button>
</div>
</form>
</div>
</div>
</body>
</html>