34 lines
1.0 KiB
PHP
Executable File
34 lines
1.0 KiB
PHP
Executable File
<?php
|
|
header('Content-Type: application/json');
|
|
require_once __DIR__ . '/../../../shared/utils/helpers.php';
|
|
require_once __DIR__ . '/../../../shared/auth/jwt.php';
|
|
require_once __DIR__ . '/../../../shared/database/connection.php';
|
|
|
|
// Verificar autenticación
|
|
$userData = JWTAuth::authenticate();
|
|
if (!$userData) {
|
|
jsonResponse(['success' => false, 'error' => 'No autenticado'], 401);
|
|
}
|
|
|
|
// Verificar permiso
|
|
if (!hasPermission('manage_recipients', 'discord')) {
|
|
jsonResponse(['success' => false, 'error' => 'No tienes permiso para eliminar destinatarios de Discord.'], 403);
|
|
}
|
|
|
|
$input = json_decode(file_get_contents('php://input'), true);
|
|
$id = $input['id'] ?? null;
|
|
|
|
if (!$id) {
|
|
jsonResponse(['success' => false, 'error' => 'ID requerido'], 400);
|
|
}
|
|
|
|
try {
|
|
$db = getDB();
|
|
$stmt = $db->prepare("DELETE FROM destinatarios_discord WHERE id = ?");
|
|
$stmt->execute([$id]);
|
|
|
|
jsonResponse(['success' => true]);
|
|
} catch (PDOException $e) {
|
|
jsonResponse(['success' => false, 'error' => $e->getMessage()], 500);
|
|
}
|