Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(web): validate destination folder matches move type in moveVideoToFolder
Richie McIlroya27d0ccbcc46
diff --git a/apps/web/actions/folders/moveVideoToFolder.ts b/apps/web/actions/folders/moveVideoToFolder.tsindex 8dbcd46ca..861f40752 100644--- a/apps/web/actions/folders/moveVideoToFolder.ts+++ b/apps/web/actions/folders/moveVideoToFolder.ts@@ -39,10 +39,18 @@ export async function moveVideoToFolder({const isAllSpacesEntry = spaceId === user.activeOrganizationId;- // If folderId is provided, verify it exists and belongs to the same organization+ // If a destination folder is provided, load it once (scoped to the caller's+ // org) so each branch can also verify the caller may WRITE to that specific+ // folder — not just that the source space/folder is manageable.+ let destinationFolder:+ | { spaceId: string | null; createdById: string }+ | undefined;if (folderId) {- const [folder] = await db()- .select()+ [destinationFolder] = await db()+ .select({+ spaceId: folders.spaceId,+ createdById: folders.createdById,+ }).from(folders).where(and(@@ -51,7 +59,7 @@ export async function moveVideoToFolder({),);- if (!folder) {+ if (!destinationFolder) {throw new Error("Folder not found or not accessible");}}@@ -62,6 +70,11 @@ export async function moveVideoToFolder({throw new Error("You don't have permission to manage this space");}+ // The destination folder must belong to the same space being managed.+ if (destinationFolder && destinationFolder.spaceId !== spaceId) {+ throw new Error("Folder not found or not accessible");+ }+await db().update(spaceVideos).set({@@ -76,6 +89,11 @@ export async function moveVideoToFolder({user.activeOrganizationId,);+ // The destination must be an org-level (non-space) folder.+ if (destinationFolder && destinationFolder.spaceId !== null) {+ throw new Error("Folder not found or not accessible");+ }+await db().update(sharedVideos).set({@@ -88,6 +106,15 @@ export async function moveVideoToFolder({),);} else {+ // Personal move: the destination must be the caller's own personal folder.+ if (+ destinationFolder &&+ (destinationFolder.spaceId !== null ||+ destinationFolder.createdById !== user.id)+ ) {+ throw new Error("Folder not found or not accessible");+ }+await db().update(videos).set({