diff --git a/.perm_test_apache b/.perm_test_apache new file mode 100644 index 0000000..e69de29 diff --git a/.perm_test_exec b/.perm_test_exec new file mode 100644 index 0000000..e69de29 diff --git a/admin.php b/admin.php new file mode 100644 index 0000000..39d7d34 --- /dev/null +++ b/admin.php @@ -0,0 +1,624 @@ +prepare('SELECT COUNT(*) FROM tbl_auth WHERE cl_auth_user = :cl_auth_user'); + $stmt_duplicate_user->execute([ + 'cl_auth_user' => $submitted_cl_auth_user, + ]); + $cl_auth_user_total = (int) $stmt_duplicate_user->fetchColumn(); + + if ($cl_auth_user_total > 0) { + auth_flash_set('error', 'Ce login existe déjà.'); + header('Location: admin.php'); + exit; + } + + $cl_auth_user = $submitted_cl_auth_user; + $cl_auth_pass = password_hash($submitted_cl_auth_pass, PASSWORD_DEFAULT); + $cl_auth_right = $submitted_cl_auth_right; + + $stmt_create_user = db()->prepare( + 'INSERT INTO tbl_auth (cl_auth_user, cl_auth_pass, cl_auth_right) VALUES (:cl_auth_user, :cl_auth_pass, :cl_auth_right)' + ); + $stmt_create_user->execute([ + 'cl_auth_user' => $cl_auth_user, + 'cl_auth_pass' => $cl_auth_pass, + 'cl_auth_right' => $cl_auth_right, + ]); + + auth_flash_set('success', 'Compte créé avec succès.'); + header('Location: admin.php'); + exit; + } + + if ($admin_action === 'update') { + $cl_auth_id = (int) ($_POST['cl_auth_id'] ?? 0); + $submitted_cl_auth_user = trim((string) ($_POST['cl_auth_user'] ?? '')); + $submitted_cl_auth_pass = (string) ($_POST['cl_auth_pass'] ?? ''); + $submitted_cl_auth_right = (string) ($_POST['cl_auth_right'] ?? 'member'); + + if ($cl_auth_id <= 0 || $submitted_cl_auth_user === '') { + auth_flash_set('error', 'Données de modification invalides.'); + header('Location: admin.php'); + exit; + } + + if (!in_array($submitted_cl_auth_right, ['admin', 'member'], true)) { + auth_flash_set('error', 'Droit utilisateur invalide.'); + header('Location: admin.php?edit=' . $cl_auth_id); + exit; + } + + $stmt_tbl_auth = db()->prepare('SELECT cl_auth_id, cl_auth_user, cl_auth_pass, cl_auth_right FROM tbl_auth WHERE cl_auth_id = :cl_auth_id LIMIT 1'); + $stmt_tbl_auth->execute([ + 'cl_auth_id' => $cl_auth_id, + ]); + $tbl_auth = $stmt_tbl_auth->fetch(); + + if (!$tbl_auth) { + auth_flash_set('error', 'Utilisateur introuvable.'); + header('Location: admin.php'); + exit; + } + + $current_cl_auth_id = (int) $tbl_auth['cl_auth_id']; + $current_cl_auth_user = (string) $tbl_auth['cl_auth_user']; + $current_cl_auth_pass = (string) $tbl_auth['cl_auth_pass']; + $current_cl_auth_right = (string) $tbl_auth['cl_auth_right']; + unset($current_cl_auth_id, $current_cl_auth_user); + + $stmt_duplicate_user = db()->prepare( + 'SELECT COUNT(*) FROM tbl_auth WHERE cl_auth_user = :cl_auth_user AND cl_auth_id <> :cl_auth_id' + ); + $stmt_duplicate_user->execute([ + 'cl_auth_user' => $submitted_cl_auth_user, + 'cl_auth_id' => $cl_auth_id, + ]); + $cl_auth_user_total = (int) $stmt_duplicate_user->fetchColumn(); + + if ($cl_auth_user_total > 0) { + auth_flash_set('error', 'Ce login existe déjà.'); + header('Location: admin.php?edit=' . $cl_auth_id); + exit; + } + + if ($current_cl_auth_right === 'admin' && $submitted_cl_auth_right !== 'admin') { + $stmt_admin_total = db()->query("SELECT COUNT(*) FROM tbl_auth WHERE cl_auth_right = 'admin'"); + $cl_auth_admin_total = (int) $stmt_admin_total->fetchColumn(); + if ($cl_auth_admin_total <= 1) { + auth_flash_set('error', 'Impossible de rétrograder le dernier administrateur.'); + header('Location: admin.php?edit=' . $cl_auth_id); + exit; + } + } + + $cl_auth_user = $submitted_cl_auth_user; + $cl_auth_right = $submitted_cl_auth_right; + $cl_auth_pass = $current_cl_auth_pass; + + if ($submitted_cl_auth_pass !== '') { + $cl_auth_pass = password_hash($submitted_cl_auth_pass, PASSWORD_DEFAULT); + } + + $stmt_update_user = db()->prepare( + 'UPDATE tbl_auth + SET cl_auth_user = :cl_auth_user, + cl_auth_pass = :cl_auth_pass, + cl_auth_right = :cl_auth_right + WHERE cl_auth_id = :cl_auth_id' + ); + $stmt_update_user->execute([ + 'cl_auth_user' => $cl_auth_user, + 'cl_auth_pass' => $cl_auth_pass, + 'cl_auth_right' => $cl_auth_right, + 'cl_auth_id' => $cl_auth_id, + ]); + + if (isset($_SESSION['user']) && $_SESSION['user'] === $tbl_auth['cl_auth_user']) { + $_SESSION['user'] = $cl_auth_user; + $_SESSION['role'] = $cl_auth_right; + } + + auth_flash_set('success', 'Compte modifié avec succès.'); + header('Location: admin.php'); + exit; + } + + if ($admin_action === 'delete') { + $cl_auth_id = (int) ($_POST['cl_auth_id'] ?? 0); + + if ($cl_auth_id <= 0) { + auth_flash_set('error', 'Suppression impossible.'); + header('Location: admin.php'); + exit; + } + + $stmt_tbl_auth = db()->prepare('SELECT cl_auth_id, cl_auth_user, cl_auth_pass, cl_auth_right FROM tbl_auth WHERE cl_auth_id = :cl_auth_id LIMIT 1'); + $stmt_tbl_auth->execute([ + 'cl_auth_id' => $cl_auth_id, + ]); + $tbl_auth = $stmt_tbl_auth->fetch(); + + if (!$tbl_auth) { + auth_flash_set('error', 'Utilisateur introuvable.'); + header('Location: admin.php'); + exit; + } + + $cl_auth_user = (string) $tbl_auth['cl_auth_user']; + $cl_auth_pass = (string) $tbl_auth['cl_auth_pass']; + $cl_auth_right = (string) $tbl_auth['cl_auth_right']; + unset($cl_auth_pass); + + if ($cl_auth_right === 'admin') { + $stmt_admin_total = db()->query("SELECT COUNT(*) FROM tbl_auth WHERE cl_auth_right = 'admin'"); + $cl_auth_admin_total = (int) $stmt_admin_total->fetchColumn(); + if ($cl_auth_admin_total <= 1) { + auth_flash_set('error', 'Impossible de supprimer le dernier administrateur.'); + header('Location: admin.php'); + exit; + } + } + + $stmt_delete_user = db()->prepare('DELETE FROM tbl_auth WHERE cl_auth_id = :cl_auth_id'); + $stmt_delete_user->execute([ + 'cl_auth_id' => $cl_auth_id, + ]); + + if (isset($_SESSION['user']) && $_SESSION['user'] === $cl_auth_user) { + header('Location: logout.php'); + exit; + } + + auth_flash_set('success', 'Compte supprimé avec succès.'); + header('Location: admin.php'); + exit; + } +} + +if ($edit_cl_auth_id > 0) { + $stmt_edit_user = db()->prepare('SELECT cl_auth_id, cl_auth_user, cl_auth_pass, cl_auth_right FROM tbl_auth WHERE cl_auth_id = :cl_auth_id LIMIT 1'); + $stmt_edit_user->execute([ + 'cl_auth_id' => $edit_cl_auth_id, + ]); + $tbl_auth = $stmt_edit_user->fetch(); + + if ($tbl_auth) { + $edit_cl_auth_id = (int) $tbl_auth['cl_auth_id']; + $edit_cl_auth_user = (string) $tbl_auth['cl_auth_user']; + $edit_cl_auth_pass = (string) $tbl_auth['cl_auth_pass']; + $edit_cl_auth_right = (string) $tbl_auth['cl_auth_right']; + unset($edit_cl_auth_pass); + } else { + $edit_cl_auth_id = 0; + auth_flash_set('error', 'Utilisateur introuvable.'); + header('Location: admin.php'); + exit; + } +} + +$stmt_users = db()->query('SELECT cl_auth_id, cl_auth_user, cl_auth_pass, cl_auth_right FROM tbl_auth ORDER BY cl_auth_user ASC'); +$tbl_auth_all = $stmt_users->fetchAll(); +$csrf_token = auth_csrf_token(); +[$default_admin_user, $default_admin_password] = auth_default_admin_credentials(); +$current_session_user = isset($_SESSION['user']) ? (string) $_SESSION['user'] : ''; +?> + + + + + + + Administration Sécure | R.E.A.C.T. + + + + + +
+
+
+

R.E.A.C.T. Core Admin

+

Niveau d\'accès : Administrateur | Session :

+
+ +
+ + +
+ +
+ + + +
+ Sécurité critique : Les identifiants par défaut sont actifs. + ( / ) +
Veuillez modifier ces accès dès maintenant. +
+ + +
+ +
+

0 ? 'Mise à jour sujet' : 'Nouveau sujet'; ?>

+
+ + + 0): + ?> + + +
+ + +
+ +
+ + 0 ? '' : 'required'; ?> placeholder="••••••••"> +
+ +
+ + +
+ +
+ + 0): + ?>Annuler + +
+
+
+ + +
+

Base de données sujets

+
+ + + + + + + + + + + + + + + + + + + + + + + +
UIDSujetAccréditationOpérations
Aucun sujet détecté dans la base.
# + + + + +
+ Editer +
+ + + + +
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/css/styles.css b/css/styles.css index f467481..b7fb638 100644 --- a/css/styles.css +++ b/css/styles.css @@ -1,3 +1,4 @@ +[hidden] { display: none !important; } @font-face { font-family: 'Electrolize'; src: url('../fonts/Electrolize-Regular.ttf') format('truetype'); @@ -309,4 +310,49 @@ a:hover { .connexion-bouton:hover { background-color: rgb(0 0 0 / 20%); cursor: pointer; -} \ No newline at end of file +} +/* Auth / admin helpers */ +.connexion-div-menu { + display: flex; + align-items: center; + gap: 12px; + flex-wrap: wrap; +} + +.connexion-div-menu #accountLabel { + display: inline-block; +} + +.connexion-div-menu.is-authenticated { + cursor: default; +} + +.connexion-actions[hidden] { display: none !important; } +.connexion-actions { + display: inline-flex; + align-items: center; + gap: 10px; +} + +.connexion-actions a { + color: #f4e3b2; + text-decoration: none; + border-bottom: 1px solid rgba(244, 227, 178, 0.35); +} + +.connexion-actions a:hover { + color: #ffffff; + border-bottom-color: rgba(255, 255, 255, 0.8); +} + +.login-status { + min-height: 18px; +} + +.login-status.is-error { + color: #ff8080; +} + +.login-status.is-success { + color: #9fe29f; +} diff --git a/db/auth.php b/db/auth.php new file mode 100644 index 0000000..c75aca2 --- /dev/null +++ b/db/auth.php @@ -0,0 +1,111 @@ +exec( + "CREATE TABLE IF NOT EXISTS tbl_auth ( + cl_auth_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + cl_auth_user VARCHAR(190) NOT NULL UNIQUE, + cl_auth_pass VARCHAR(255) NOT NULL, + cl_auth_right ENUM('admin', 'member') NOT NULL DEFAULT 'member' + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" + ); + + $sql_count_admin = "SELECT COUNT(*) FROM tbl_auth WHERE cl_auth_right = 'admin'"; + $stmt_count_admin = $pdo->query($sql_count_admin); + $cl_auth_admin_total = (int) $stmt_count_admin->fetchColumn(); + + if ($cl_auth_admin_total === 0) { + [$cl_auth_user, $plain_default_password] = auth_default_admin_credentials(); + $cl_auth_pass = password_hash($plain_default_password, PASSWORD_DEFAULT); + $cl_auth_right = 'admin'; + + $stmt_insert_admin = $pdo->prepare( + 'INSERT INTO tbl_auth (cl_auth_user, cl_auth_pass, cl_auth_right) VALUES (:cl_auth_user, :cl_auth_pass, :cl_auth_right)' + ); + $stmt_insert_admin->execute([ + 'cl_auth_user' => $cl_auth_user, + 'cl_auth_pass' => $cl_auth_pass, + 'cl_auth_right' => $cl_auth_right, + ]); + } + + $auth_bootstrap_done = true; +} + +function auth_default_admin_credentials(): array +{ + return ['admin', 'ReactAdmin!2026']; +} + +function auth_csrf_token(): string +{ + auth_start_session(); + + if (empty($_SESSION['csrf_token']) || !is_string($_SESSION['csrf_token'])) { + $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); + } + + return $_SESSION['csrf_token']; +} + +function auth_validate_csrf(?string $csrf_token): bool +{ + auth_start_session(); + + if (!isset($_SESSION['csrf_token']) || !is_string($_SESSION['csrf_token'])) { + return false; + } + + if ($csrf_token === null) { + return false; + } + + return hash_equals($_SESSION['csrf_token'], $csrf_token); +} + +function auth_is_admin(): bool +{ + auth_start_session(); + + return isset($_SESSION['role']) && $_SESSION['role'] === 'admin'; +} + +function auth_flash_set(string $flash_type, string $flash_message): void +{ + auth_start_session(); + $_SESSION['flash'] = [ + 'type' => $flash_type, + 'message' => $flash_message, + ]; +} + +function auth_flash_get(): ?array +{ + auth_start_session(); + + if (!isset($_SESSION['flash']) || !is_array($_SESSION['flash'])) { + return null; + } + + $flash = $_SESSION['flash']; + unset($_SESSION['flash']); + + return $flash; +} diff --git a/db/config.php b/db/config.php new file mode 100644 index 0000000..845f555 --- /dev/null +++ b/db/config.php @@ -0,0 +1,17 @@ + PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + ]); + } + return $pdo; +} diff --git a/index-en.php b/index-en.php index 7f2d64c..4fc9d9c 100644 --- a/index-en.php +++ b/index-en.php @@ -1,172 +1,190 @@ - - - - - - - - - Rapid Emergency & Action Combat Team / Star Citizen - - - - - - - - - - -
Connexion
- -
- 🇫🇷 - 🇬🇧 -
- - - - - -
- -
-
- -

Rapid Emergency & Action Combat Team

- -

Founded to combat extreme criminality across the Verse. R.E.A.C.T. is an independent operational label, uniting dedicated pilots from all horizons to neutralize threats where the law is failing.

-

—————— R.E.A.C.T. is not an organization, but a tactical standard ——————

-

It is a cross-org initiative designed for players who share the same vision: protecting citizens and NPCs from hostile entities. Wearing the R.E.A.C.T. badge doesn’t mean leaving your organization; it means joining a rapid response network.

-
-
- -
-
- -
- - - - -
- - - - - - - - - - - - - - - - + + + + + + + + + + Rapid Emergency & Action Combat Team / Star Citizen + + + + + + + + + + +
id="accountPanel"> + + > + >Admin + Déconnexion + +
+ +
+ 🇫🇷 + 🇬🇧 +
+ + + + + +
+ +
+
+ +

Rapid Emergency & Action Combat Team

+ +

Founded to combat extreme criminality across the Verse. R.E.A.C.T. is an independent operational label, uniting dedicated pilots from all horizons to neutralize threats where the law is failing.

+

—————— R.E.A.C.T. is not an organization, but a tactical standard ——————

+

It is a cross-org initiative designed for players who share the same vision: protecting citizens and NPCs from hostile entities. Wearing the R.E.A.C.T. badge doesn’t mean leaving your organization; it means joining a rapid response network.

+
+
+ +
+
+ +
+ + + + +
+ + + + + + + + + + + + + + + + + diff --git a/index.php b/index.php index 7e37f61..28434d3 100644 --- a/index.php +++ b/index.php @@ -1,176 +1,194 @@ - - - - - - - - - Rapid Emergency & Action Combat Team / Star Citizen - - - - - - - - - - -
- Contenu à venir -
- -
Connexion
- -
- 🇫🇷 - 🇬🇧 -
- - - - - -
- -
-
- -

Rapid Emergency & Action Combat Team

- -

Fondée pour combattre la criminalité extrême à travers l’Univers, la R.E.A.C.T. est un label opérationnel indépendant. Nous unissons des pilotes dévoués de tous horizons pour neutraliser les menaces là où la loi fait défaut.

-

—————— La R.E.A.C.T. n’est pas une organisation, mais un standard tactique ——————

-

C’est une initiative inter-organisations conçue pour les joueurs qui partagent la même vision : protéger les citoyens et les PNJs des entités hostiles. Porter l’insigne R.E.A.C.T. ne signifie pas quitter votre organisation ; cela signifie rejoindre un réseau d'intervention rapide.

-
-
- -
-
- -
- - - - -
- - - - - - - - - - - - - - - - + + + + + + + + + + Rapid Emergency & Action Combat Team / Star Citizen + + + + + + + + + + +
+ Contenu à venir +
+ +
id="accountPanel"> + + > + >Admin + Déconnexion + +
+ +
+ 🇫🇷 + 🇬🇧 +
+ + + + + +
+ +
+
+ +

Rapid Emergency & Action Combat Team

+ +

Fondée pour combattre la criminalité extrême à travers l’Univers, la R.E.A.C.T. est un label opérationnel indépendant. Nous unissons des pilotes dévoués de tous horizons pour neutraliser les menaces là où la loi fait défaut.

+

—————— La R.E.A.C.T. n’est pas une organisation, mais un standard tactique ——————

+

C’est une initiative inter-organisations conçue pour les joueurs qui partagent la même vision : protéger les citoyens et les PNJs des entités hostiles. Porter l’insigne R.E.A.C.T. ne signifie pas quitter votre organisation ; cela signifie rejoindre un réseau d'intervention rapide.

+
+
+ +
+
+ +
+ + + + +
+ + + + + + + + + + + + + + + + + diff --git a/js/auth.js b/js/auth.js new file mode 100644 index 0000000..4fa61e4 --- /dev/null +++ b/js/auth.js @@ -0,0 +1,122 @@ +(function () { + var loginForm = document.querySelector('.js-login-form'); + var accountPanel = document.getElementById('accountPanel'); + var accountLabel = document.getElementById('accountLabel'); + var accountActions = document.getElementById('accountActions'); + var adminLink = document.getElementById('adminLink'); + var logoutLink = document.getElementById('logoutLink'); + var loginStatus = document.getElementById('loginStatus'); + var loginModal = document.getElementById('modal-Login'); + var overlay = document.querySelector('.md-overlay'); + + if (!loginForm || !accountPanel || !accountLabel || !accountActions || !logoutLink) { + return; + } + + function setStatus(message, isError) { + if (!loginStatus) { + return; + } + + loginStatus.textContent = message || ''; + loginStatus.classList.toggle('is-error', !!isError); + loginStatus.classList.toggle('is-success', !isError && !!message); + } + + function closeModal() { + if (loginModal) { + loginModal.classList.remove('md-show'); + } + if (document.documentElement) { + document.documentElement.classList.remove('md-perspective'); + } + if (overlay) { + overlay.removeEventListener('click', closeModal); + } + } + + function renderAuthenticated(user, role, adminUrl, logoutUrl) { + accountPanel.classList.add('is-authenticated'); + accountPanel.classList.remove('md-trigger'); + accountPanel.removeAttribute('data-modal'); + accountLabel.textContent = user; + accountActions.hidden = false; + + if (role === 'admin' && adminUrl) { + adminLink.href = adminUrl; + adminLink.hidden = false; + } else { + adminLink.hidden = true; + } + + if (logoutUrl) { + logoutLink.href = logoutUrl; + } + } + + function renderLoggedOut(defaultLabel) { + accountPanel.classList.remove('is-authenticated'); + accountPanel.classList.add('md-trigger'); + accountPanel.setAttribute('data-modal', 'modal-Login'); + accountLabel.textContent = defaultLabel; + accountActions.hidden = true; + adminLink.hidden = true; + } + + loginForm.addEventListener('submit', function (event) { + event.preventDefault(); + setStatus('', false); + + var formData = new FormData(loginForm); + + fetch('login.php', { + method: 'POST', + headers: { + 'X-Requested-With': 'XMLHttpRequest' + }, + body: formData + }) + .then(function (response) { + return response.json().then(function (payload) { + return { + ok: response.ok, + payload: payload + }; + }); + }) + .then(function (result) { + if (!result.ok || !result.payload.success) { + throw new Error(result.payload.message || 'Connexion impossible.'); + } + + renderAuthenticated(result.payload.user, result.payload.role, result.payload.adminUrl, result.payload.logoutUrl); + setStatus(result.payload.message || 'Connexion réussie.', false); + loginForm.reset(); + window.setTimeout(closeModal, 250); + }) + .catch(function (error) { + setStatus(error.message || 'Connexion impossible.', true); + }); + }); + + logoutLink.addEventListener('click', function (event) { + event.preventDefault(); + + fetch(logoutLink.href, { + method: 'POST', + headers: { + 'X-Requested-With': 'XMLHttpRequest' + } + }) + .then(function (response) { + return response.json(); + }) + .then(function () { + renderLoggedOut(accountPanel.dataset.loginLabel || 'Connexion'); + setStatus('', false); + }) + .catch(function () { + window.location.href = logoutLink.href; + }); + }); +})(); diff --git a/login.php b/login.php new file mode 100644 index 0000000..8d2fa49 --- /dev/null +++ b/login.php @@ -0,0 +1,89 @@ + false, + 'message' => 'Méthode non autorisée.', + ], JSON_UNESCAPED_UNICODE); + exit; +} + +$submitted_cl_auth_user = trim((string) ($_POST['cl_auth_user'] ?? '')); +$submitted_cl_auth_pass = (string) ($_POST['cl_auth_pass'] ?? ''); + +if ($submitted_cl_auth_user === '' || $submitted_cl_auth_pass === '') { + http_response_code(422); + echo json_encode([ + 'success' => false, + 'message' => 'Identifiants incomplets.', + ], JSON_UNESCAPED_UNICODE); + exit; +} + +$stmt_tbl_auth = db()->prepare( + 'SELECT cl_auth_id, cl_auth_user, cl_auth_pass, cl_auth_right + FROM tbl_auth + WHERE cl_auth_user = :cl_auth_user + LIMIT 1' +); +$stmt_tbl_auth->execute([ + 'cl_auth_user' => $submitted_cl_auth_user, +]); +$tbl_auth = $stmt_tbl_auth->fetch(); + +if (!$tbl_auth) { + http_response_code(401); + echo json_encode([ + 'success' => false, + 'message' => 'Identifiants invalides.', + ], JSON_UNESCAPED_UNICODE); + exit; +} + +$cl_auth_id = (int) $tbl_auth['cl_auth_id']; +$cl_auth_user = (string) $tbl_auth['cl_auth_user']; +$cl_auth_pass = (string) $tbl_auth['cl_auth_pass']; +$cl_auth_right = (string) $tbl_auth['cl_auth_right']; +unset($cl_auth_id); + +if (!password_verify($submitted_cl_auth_pass, $cl_auth_pass)) { + http_response_code(401); + echo json_encode([ + 'success' => false, + 'message' => 'Identifiants invalides.', + ], JSON_UNESCAPED_UNICODE); + exit; +} + +if (password_needs_rehash($cl_auth_pass, PASSWORD_DEFAULT)) { + $rehash_cl_auth_pass = password_hash($submitted_cl_auth_pass, PASSWORD_DEFAULT); + $stmt_update_password = db()->prepare( + 'UPDATE tbl_auth SET cl_auth_pass = :cl_auth_pass WHERE cl_auth_user = :cl_auth_user' + ); + $stmt_update_password->execute([ + 'cl_auth_pass' => $rehash_cl_auth_pass, + 'cl_auth_user' => $cl_auth_user, + ]); +} + +session_regenerate_id(true); +$_SESSION['user'] = $cl_auth_user; +$_SESSION['role'] = $cl_auth_right; +$_SESSION['csrf_token'] = bin2hex(random_bytes(32)); + +echo json_encode([ + 'success' => true, + 'message' => 'Connexion réussie.', + 'user' => $cl_auth_user, + 'role' => $cl_auth_right, + 'adminUrl' => 'admin.php', + 'logoutUrl' => 'logout.php', +], JSON_UNESCAPED_UNICODE); diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..5d3bc6a --- /dev/null +++ b/logout.php @@ -0,0 +1,36 @@ + true, + 'message' => 'Déconnexion effectuée.', + ], JSON_UNESCAPED_UNICODE); + exit; +} + +header('Location: index.php'); +exit;