2
0

Revert new authentication method for preview bot

This commit is contained in:
Baptiste Arnaud
2023-11-13 15:45:11 +01:00
parent 084588a086
commit 06065c3e85
6 changed files with 26 additions and 43 deletions

View File

@ -39,7 +39,7 @@ import { VisitedEdge } from '@typebot.io/prisma'
type StartParams =
| ({
type: 'preview'
userId: string
userId?: string
} & StartPreviewChatInput)
| ({
type: 'live'
@ -272,6 +272,13 @@ export const startSession = async ({
const getTypebot = async (startParams: StartParams): Promise<StartTypebot> => {
if (startParams.type === 'preview' && startParams.typebot)
return startParams.typebot
if (startParams.type === 'preview' && !startParams.userId)
throw new TRPCError({
code: 'UNAUTHORIZED',
message: 'You need to be authenticated to perform this action',
})
const typebotQuery =
startParams.type === 'preview'
? await findTypebot({