Skip to content

Commit

Permalink
🚑 (editor) Fix typebot update permission
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Nov 23, 2023
1 parent ca79934 commit 8a07392
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const getLinkedTypebots = authenticatedProcedure
createdAt: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down Expand Up @@ -109,7 +109,7 @@ export const getLinkedTypebots = authenticatedProcedure
createdAt: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const getCollaborators = authenticatedProcedure
collaborators: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/results/api/deleteResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const deleteResults = authenticatedProcedure
groups: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/results/api/getResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const getResult = authenticatedProcedure
groups: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/results/api/getResultLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const getResultLogs = authenticatedProcedure
groups: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/results/api/getResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const getResults = authenticatedProcedure
},
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/typebot/api/deleteTypebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const deleteTypebot = authenticatedProcedure
groups: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const getPublishedTypebot = authenticatedProcedure
publishedTypebot: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/typebot/api/getTypebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const getTypebot = authenticatedProcedure
collaborators: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/typebot/api/publishTypebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const publishTypebot = authenticatedProcedure
workspace: {
select: {
plan: true,
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/typebot/api/unpublishTypebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const unpublishTypebot = authenticatedProcedure
publishedTypebot: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/typebot/api/updateTypebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const updateTypebot = authenticatedProcedure
select: {
id: true,
plan: true,
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export const isReadTypebotForbidden = async (
typebot: {
collaborators: Pick<CollaboratorsOnTypebots, 'userId'>[]
} & {
workspace: Pick<Workspace, 'isQuarantined' | 'isPastDue'> & {
workspace: Pick<Workspace, 'isSuspended' | 'isPastDue'> & {
members: Pick<MemberInWorkspace, 'userId'>[]
}
},
user: Pick<User, 'email' | 'id'>
) =>
typebot.workspace.isQuarantined ||
typebot.workspace.isSuspended ||
typebot.workspace.isPastDue ||
(env.ADMIN_EMAIL !== user.email &&
!typebot.collaborators.some(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ export const isWriteTypebotForbidden = async (
typebot: {
collaborators: Pick<CollaboratorsOnTypebots, 'userId' | 'type'>[]
} & {
workspace: Pick<Workspace, 'isQuarantined' | 'isPastDue'> & {
workspace: Pick<Workspace, 'isSuspended' | 'isPastDue'> & {
members: Pick<MemberInWorkspace, 'userId' | 'role'>[]
}
},
user: Pick<User, 'id'>
) => {
return (
typebot.workspace.isQuarantined ||
typebot.workspace.isSuspended ||
typebot.workspace.isPastDue ||
!(
typebot.collaborators.find(
(collaborator) => collaborator.userId === user.id
)?.type === CollaborationType.WRITE &&
typebot.workspace.members.some(
(!typebot.collaborators.some(
(collaborator) =>
collaborator.userId === user.id &&
collaborator.type === CollaborationType.WRITE
) &&
!typebot.workspace.members.some(
(m) => m.userId === user.id && m.role !== 'GUEST'
)
)
))
)
}
2 changes: 1 addition & 1 deletion apps/builder/src/features/upload/api/generateUploadUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const parseFilePath = async ({
workspace: {
select: {
plan: true,
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/whatsapp/startWhatsAppPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const startWhatsAppPreview = authenticatedProcedure
id: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
Expand Down

1 comment on commit 8a07392

@vercel
Copy link

@vercel vercel bot commented on 8a07392 Nov 23, 2023

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

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

Please sign in to comment.