<?php
// POST /api/logout

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    sendError('Method not allowed', 405);
}

$payload = authenticate();

$db = getDB();
$stmt = $db->prepare("UPDATE devices SET token = NULL WHERE device_id = ?");
$stmt->bind_param("s", $payload['device_id']);
$stmt->execute();
$stmt->close();
$db->close();

sendSuccess([], 'Logged out successfully');
