31 lines
890 B
PHP
31 lines
890 B
PHP
<?php
|
|
require_once '../include/init.php';
|
|
require_once '../include/auth.php'; // ensures user is logged in and is admin
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
if (!isAdmin()) {
|
|
http_response_code(403); // Forbidden
|
|
echo json_encode(['error' => 'You do not have permission to perform this action.']);
|
|
exit;
|
|
}
|
|
|
|
$tab_id = $_POST['tab_id'] ?? null;
|
|
|
|
if (!$tab_id) {
|
|
http_response_code(400); // Bad Request
|
|
echo json_encode(['error' => 'Tab ID is required.']);
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
// Set the token to NULL in the database
|
|
$stmt = $pdo->prepare("UPDATE tabs SET login_token = NULL WHERE id = ?");
|
|
$stmt->execute([$tab_id]);
|
|
|
|
echo json_encode(['success' => true]);
|
|
} catch (Exception $e) {
|
|
http_response_code(500); // Internal Server Error
|
|
echo json_encode(['error' => 'Failed to clear token: ' . $e->getMessage()]);
|
|
}
|