fix: correctly conditionally add captcha fields to invite payload
This commit is contained in:
@@ -87,15 +87,17 @@ export async function sendInvitation(
|
|||||||
role: string = 'member',
|
role: string = 'member',
|
||||||
captcha?: { captcha_id?: string, captcha_solution?: string, captcha_token?: string }
|
captcha?: { captcha_id?: string, captcha_solution?: string, captcha_token?: string }
|
||||||
): Promise<OrganizationInvitation> {
|
): Promise<OrganizationInvitation> {
|
||||||
|
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<OrganizationInvitation>(`/auth/organizations/${organizationId}/invites`, {
|
return await authFetch<OrganizationInvitation>(`/auth/organizations/${organizationId}/invites`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify(body),
|
||||||
email,
|
|
||||||
role,
|
|
||||||
captcha_id: captcha?.captcha_id,
|
|
||||||
captcha_solution: captcha?.captcha_solution,
|
|
||||||
captcha_token: captcha?.captcha_token
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user