fix(auth): support array bodies in integration authentication

This commit is contained in:
Marcos Fargas
2026-10-12 20:45:56 +02:00
parent 317a3aa46d
commit 9276dba00d

View File

@@ -51,14 +51,22 @@ export async function authenticateIntegrationRequest(
req.nextUrl.searchParams.get('client_id'); req.nextUrl.searchParams.get('client_id');
if (!tenantId && options.parsedBody) { if (!tenantId && options.parsedBody) {
if (Array.isArray(options.parsedBody)) {
tenantId = options.parsedBody[0]?.tenant_id || options.parsedBody[0]?.client_id;
} else {
tenantId = options.parsedBody.tenant_id || options.parsedBody.client_id; tenantId = options.parsedBody.tenant_id || options.parsedBody.client_id;
} }
}
if (!tenantId && req.method !== 'GET') { if (!tenantId && req.method !== 'GET') {
try { try {
const cloned = req.clone(); const cloned = req.clone();
const body = await cloned.json(); const body = await cloned.json();
if (Array.isArray(body)) {
tenantId = body[0]?.tenant_id || body[0]?.client_id;
} else {
tenantId = body.tenant_id || body.client_id; tenantId = body.tenant_id || body.client_id;
}
} catch { } catch {
// Ignorar // Ignorar
} }