Skip to content

Commit

Permalink
🛂 Allow app admin to read a typebot
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Nov 27, 2023
1 parent 880ded9 commit cf8df68
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/builder/src/features/typebot/api/getTypebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { z } from 'zod'
import { isReadTypebotForbidden } from '../helpers/isReadTypebotForbidden'
import { migrateTypebot } from '@typebot.io/lib/migrations/migrateTypebot'
import { CollaborationType } from '@typebot.io/prisma'
import { env } from '@typebot.io/env'

export const getTypebot = publicProcedure
.meta({
Expand Down Expand Up @@ -81,11 +82,12 @@ export const getTypebot = publicProcedure
)

const getCurrentUserMode = (
user: { id: string } | undefined,
user: { email: string | null; id: string } | undefined,
typebot: { collaborators: { userId: string; type: CollaborationType }[] } & {
workspace: { members: { userId: string }[] }
}
) => {
if (user?.email === env.ADMIN_EMAIL) return 'read'
const collaborator = typebot.collaborators.find((c) => c.userId === user?.id)
const isMemberOfWorkspace = typebot.workspace.members.some(
(m) => m.userId === user?.id
Expand Down

0 comments on commit cf8df68

Please sign in to comment.