<?php
// logout.php - Logout Handler

session_start();

require_once __DIR__ . '/config/config.php';
require_once __DIR__ . '/src/Database.php';
require_once __DIR__ . '/src/OAuth.php';

if (isset($_SESSION['user_id'])) {
    $oauth = new OAuth(GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, GOOGLE_REDIRECT_URI);
    $oauth->revokeToken($_SESSION['user_id']);
}

// Destroy session
session_destroy();

// Redirect to login
header('Location: login.php?logout=success');
exit;

?>