From 8552cc237bc65b158f4533b51817b05cced42af1 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Mon, 28 Feb 2022 10:07:36 +0100 Subject: [PATCH] =?UTF-8?q?fix(editor):=20=F0=9F=90=9B=20Fix=20basic=20aut?= =?UTF-8?q?h=20header=20without=20':'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layouts/dashboard/TemplatesContent.tsx | 1 - apps/builder/services/typebots/typebots.ts | 15 ++++++++++++--- .../[blockId]/steps/[stepId]/executeWebhook.ts | 5 ++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/builder/layouts/dashboard/TemplatesContent.tsx b/apps/builder/layouts/dashboard/TemplatesContent.tsx index d714d998a..788ccead8 100644 --- a/apps/builder/layouts/dashboard/TemplatesContent.tsx +++ b/apps/builder/layouts/dashboard/TemplatesContent.tsx @@ -39,7 +39,6 @@ export const TemplatesContent = () => { const { error, data } = typebot ? await importTypebot({ ...typebot, - id: generate(), ownerId: user.id, folderId, }) diff --git a/apps/builder/services/typebots/typebots.ts b/apps/builder/services/typebots/typebots.ts index 4de3e04f6..fa94374cc 100644 --- a/apps/builder/services/typebots/typebots.ts +++ b/apps/builder/services/typebots/typebots.ts @@ -91,12 +91,21 @@ export const createTypebot = async ({ }) } -export const importTypebot = async (typebot: Typebot) => - sendRequest({ +export const importTypebot = async (typebot: Typebot) => { + const typebotToImport: Omit = omit( + { + ...typebot, + publishedTypebotId: null, + publicId: null, + }, + 'id' + ) + return sendRequest({ url: `/api/typebots`, method: 'POST', - body: typebot, + body: typebotToImport, }) +} export const duplicateTypebot = async (typebotId: string) => { const { data } = await getTypebot(typebotId) diff --git a/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/executeWebhook.ts b/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/executeWebhook.ts index 4e4d4e3e8..96eb750c9 100644 --- a/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/executeWebhook.ts +++ b/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/executeWebhook.ts @@ -68,7 +68,10 @@ const executeWebhook = h.key?.toLowerCase() === 'authorization' && h.value?.toLowerCase()?.includes('basic') ) - if (basicAuthHeaderIdx !== -1) { + const isUsernamePasswordBasicAuth = + basicAuthHeaderIdx !== -1 && + webhook.headers[basicAuthHeaderIdx].value?.includes(':') + if (isUsernamePasswordBasicAuth) { const [username, password] = webhook.headers[basicAuthHeaderIdx].value?.slice(6).split(':') ?? [] basicAuth.username = username