Skip to content

Commit a350443

Browse files
committed
refactor(files.js): Improve file deletion process
1 parent e3e5240 commit a350443

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

api/server/routes/files/files.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ router.delete('/', async (req, res) => {
6666
return;
6767
}
6868

69-
await processDeleteRequest({ req, files });
69+
const fileIds = files.map((file) => file.file_id);
70+
const userFiles = await getFiles({ file_id: { $in: fileIds }, user: req.user.id });
71+
if (userFiles.length !== files.length) {
72+
return res.status(403).json({ message: 'You can only delete your own files' });
73+
}
74+
75+
await processDeleteRequest({ req, files: userFiles });
7076

7177
logger.debug(
7278
`[/files] Files deleted successfully: ${files

0 commit comments

Comments
 (0)