2
0

🚑 (editor) Fix typebot update permission

This commit is contained in:
Baptiste Arnaud
2023-11-23 08:28:18 +01:00
parent ca79934ef5
commit 8a07392821
16 changed files with 26 additions and 26 deletions

View File

@ -58,7 +58,7 @@ export const getLinkedTypebots = authenticatedProcedure
createdAt: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {
@ -109,7 +109,7 @@ export const getLinkedTypebots = authenticatedProcedure
createdAt: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -34,7 +34,7 @@ export const getCollaborators = authenticatedProcedure
collaborators: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -39,7 +39,7 @@ export const deleteResults = authenticatedProcedure
groups: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -36,7 +36,7 @@ export const getResult = authenticatedProcedure
groups: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -31,7 +31,7 @@ export const getResultLogs = authenticatedProcedure
groups: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -53,7 +53,7 @@ export const getResults = authenticatedProcedure
},
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -36,7 +36,7 @@ export const deleteTypebot = authenticatedProcedure
groups: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -54,7 +54,7 @@ export const getPublishedTypebot = authenticatedProcedure
publishedTypebot: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -43,7 +43,7 @@ export const getTypebot = authenticatedProcedure
collaborators: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -46,7 +46,7 @@ export const publishTypebot = authenticatedProcedure
workspace: {
select: {
plan: true,
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -34,7 +34,7 @@ export const unpublishTypebot = authenticatedProcedure
publishedTypebot: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -89,7 +89,7 @@ export const updateTypebot = authenticatedProcedure
select: {
id: true,
plan: true,
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -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(

View File

@ -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'
)
)
))
)
}

View File

@ -150,7 +150,7 @@ const parseFilePath = async ({
workspace: {
select: {
plan: true,
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {

View File

@ -59,7 +59,7 @@ export const startWhatsAppPreview = authenticatedProcedure
id: true,
workspace: {
select: {
isQuarantined: true,
isSuspended: true,
isPastDue: true,
members: {
select: {