<?php
require '../db.php';
require '../functions.php';

header('Content-Type: application/json');
$checker = requireCheckerToken($pdo);

try {
    $stmt = $pdo->prepare("UPDATE ticketchecker SET apitoken = NULL WHERE id = ?");
    $stmt->execute([$checker['id']]);

    logActivity($pdo, 'ticketchecker', $checker['id'], 'logout', 'ticketchecker', $checker['id'], 'Checker logged out of app');

    jsonOut(true, 'Logged out successfully');
} catch (Exception $e) {
    logDebug('[api_checkerlogout] ' . $e->getMessage());
    jsonOut(false, 'Something went wrong. Please try again.');
}
