From acb92728e331aa215fd2d6dbc652adf8c11fec3e Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Sun, 25 Jan 2026 00:08:30 +0100 Subject: [PATCH] fix: correctly conditionally add captcha fields to invite payload --- lib/api/organization.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/api/organization.ts b/lib/api/organization.ts index 5fcac13..02bde22 100644 --- a/lib/api/organization.ts +++ b/lib/api/organization.ts @@ -87,15 +87,17 @@ export async function sendInvitation( role: string = 'member', captcha?: { captcha_id?: string, captcha_solution?: string, captcha_token?: string } ): Promise { + const body = { + email, + role, + ...(captcha?.captcha_id ? { captcha_id: captcha.captcha_id } : {}), + ...(captcha?.captcha_solution ? { captcha_solution: captcha.captcha_solution } : {}), + ...(captcha?.captcha_token ? { captcha_token: captcha.captcha_token } : {}) + } + return await authFetch(`/auth/organizations/${organizationId}/invites`, { method: 'POST', - body: JSON.stringify({ - email, - role, - captcha_id: captcha?.captcha_id, - captcha_solution: captcha?.captcha_solution, - captcha_token: captcha?.captcha_token - }), + body: JSON.stringify(body), }) }