Front + gestion des utilisateurs
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/auth.php';
|
||||
require_once __DIR__ . '/../database.php';
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
try {
|
||||
|
||||
$data = json_decode(
|
||||
file_get_contents('php://input'),
|
||||
true
|
||||
);
|
||||
|
||||
$id = (int)($data['id'] ?? 0);
|
||||
|
||||
if ($id <= 0) {
|
||||
throw new Exception(
|
||||
'Utilisateur invalide.'
|
||||
);
|
||||
}
|
||||
|
||||
$sql = "
|
||||
UPDATE login
|
||||
SET actif = IF(actif = 1, 0, 1)
|
||||
WHERE id = :id
|
||||
";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
$stmt->execute([
|
||||
':id' => $id
|
||||
]);
|
||||
|
||||
echo json_encode([
|
||||
'success' => true
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
} catch (Exception $e) {
|
||||
|
||||
http_response_code(400);
|
||||
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => $e->getMessage()
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
Reference in New Issue
Block a user