fix(auth): support array bodies in integration authentication
This commit is contained in:
@@ -51,14 +51,22 @@ export async function authenticateIntegrationRequest(
|
||||
req.nextUrl.searchParams.get('client_id');
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tenantId && req.method !== 'GET') {
|
||||
try {
|
||||
const cloned = req.clone();
|
||||
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;
|
||||
}
|
||||
} catch {
|
||||
// Ignorar
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user