Skip to content

Commit

Permalink
fix(editor): 🐛 Fix basic auth header without ':'
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 28, 2022
1 parent b0d7be4 commit 8552cc2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 0 additions & 1 deletion apps/builder/layouts/dashboard/TemplatesContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const TemplatesContent = () => {
const { error, data } = typebot
? await importTypebot({
...typebot,
id: generate(),
ownerId: user.id,
folderId,
})
Expand Down
15 changes: 12 additions & 3 deletions apps/builder/services/typebots/typebots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,21 @@ export const createTypebot = async ({
})
}

export const importTypebot = async (typebot: Typebot) =>
sendRequest<Typebot>({
export const importTypebot = async (typebot: Typebot) => {
const typebotToImport: Omit<Typebot, 'id'> = omit(
{
...typebot,
publishedTypebotId: null,
publicId: null,
},
'id'
)
return sendRequest<Typebot>({
url: `/api/typebots`,
method: 'POST',
body: typebot,
body: typebotToImport,
})
}

export const duplicateTypebot = async (typebotId: string) => {
const { data } = await getTypebot(typebotId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit 8552cc2

@vercel
Copy link

@vercel vercel bot commented on 8552cc2 Feb 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app
app.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 8552cc2 Feb 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.