<?php

declare(strict_types=1);

require_once "../db.php";
require_once "./customer_auth_common.php";

error_reporting(E_ERROR | E_PARSE);
ini_set("display_errors", "0");

if (($_SERVER["REQUEST_METHOD"] ?? "") !== "POST") {
    customerAuthJsonResponse(405, [
        "success" => false,
        "message" => "Method not allowed",
    ]);
}

$token = customerAuthExtractBearerToken();
if ($token === "") {
    customerAuthJsonResponse(200, [
        "success" => true,
        "message" => "Logged out.",
    ]);
}

customerAuthRevokeSession($conn, $token);

customerAuthJsonResponse(200, [
    "success" => true,
    "message" => "Logged out.",
]);

