Skip to content

Commit 8e5e67b

Browse files
committed
fix(uploads): require workspace write+ for execution presigned, admin-only for workspace-logos, suppress doubled error toast
1 parent 56b90ef commit 8e5e67b

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

apps/sim/app/api/files/presigned/route.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
167167
)
168168
}
169169

170+
const permission = await getUserEntityPermissions(sessionUserId, 'workspace', workspaceId)
171+
if (permission !== 'write' && permission !== 'admin') {
172+
return NextResponse.json(
173+
{ error: 'Write or Admin access required for execution uploads' },
174+
{ status: 403 }
175+
)
176+
}
177+
170178
const fileValidationError = validateFileType(fileName, contentType)
171179
if (fileValidationError) {
172180
throw new ValidationError(fileValidationError.message)
@@ -192,9 +200,9 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
192200
}
193201

194202
const permission = await getUserEntityPermissions(sessionUserId, 'workspace', workspaceId)
195-
if (permission !== 'write' && permission !== 'admin') {
203+
if (permission !== 'admin') {
196204
return NextResponse.json(
197-
{ error: 'Write or Admin access required for workspace logo uploads' },
205+
{ error: 'Admin access required for workspace logo uploads' },
198206
{ status: 403 }
199207
)
200208
}

apps/sim/hooks/queries/workspace-files.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,11 @@ export function useUploadWorkspaceFile() {
331331
},
332332
onError: (error, variables) => {
333333
logger.error('Failed to upload file:', error)
334-
toast.error(`Failed to upload "${variables.file.name}": ${error.message}`, {
335-
duration: 5000,
336-
})
334+
if (!variables.skipToast) {
335+
toast.error(`Failed to upload "${variables.file.name}": ${error.message}`, {
336+
duration: 5000,
337+
})
338+
}
337339
},
338340
})
339341
}

0 commit comments

Comments
 (0)