Front + gestion des utilisateurs
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
/*
|
||||
* =========================================================
|
||||
* SESSION
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
session_set_cookie_params([
|
||||
'lifetime' => 0,
|
||||
'path' => '/',
|
||||
'secure' => !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off',
|
||||
'httponly' => true,
|
||||
'samesite' => 'Strict'
|
||||
]);
|
||||
|
||||
session_start();
|
||||
|
||||
|
||||
/*
|
||||
* =========================================================
|
||||
* VERIFICATION AUTHENTIFICATION
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
if (
|
||||
empty($_SESSION['user_id']) ||
|
||||
empty($_SESSION['authenticated'])
|
||||
) {
|
||||
|
||||
http_response_code(401);
|
||||
|
||||
header(
|
||||
'Content-Type: application/json; charset=utf-8'
|
||||
);
|
||||
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => 'Authentification requise.'
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
exit;
|
||||
}
|
||||
Reference in New Issue
Block a user