From 9e7637582dec0fb92d02f1774497e6fd864b249c Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Wed, 24 Jun 2026 09:27:03 -0500 Subject: [PATCH] fix(api): agregar db() helper, corregir requireAuth() en check_whatsapp Co-Authored-By: Claude Sonnet 4.6 --- api/lab/_helpers.php | 7 +++++++ api/lab/check_whatsapp.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/api/lab/_helpers.php b/api/lab/_helpers.php index 038501b..4e87577 100644 --- a/api/lab/_helpers.php +++ b/api/lab/_helpers.php @@ -48,6 +48,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { requireAuthentication(); +/** + * Shorthand para obtener la conexión PDO. + */ +function db(): \PDO { + return Database::getInstance()->getConnection(); +} + /** * ID del admin autenticado actualmente. */ diff --git a/api/lab/check_whatsapp.php b/api/lab/check_whatsapp.php index 9029105..7dc1ad8 100644 --- a/api/lab/check_whatsapp.php +++ b/api/lab/check_whatsapp.php @@ -4,7 +4,7 @@ * Verifica si un número de teléfono está registrado en WhatsApp (tabla users). */ require_once __DIR__ . '/_helpers.php'; -requireAuth(); +// requireAuthentication() ya fue llamado por _helpers.php $phone = trim($_GET['phone'] ?? ''); if (!$phone) { jsonError('phone requerido', 400); }