fix: documents.duplicate returns 403 for an unknown collectionId (#14750)

This commit is contained in:
Tom Moor authored and GitHub committed 2026-11-26 19:01:36 -05:00
1 parent 12862f5c18
commit 9d39e07a7d
2 files changed
+19 -1

No files matched your search

@@ -9768,6 +9768,24 @@ describe("#documents.duplicate", () => {
expect(res.status).toEqual(401);
});
it("should fail with status 403 for an unknown collectionId", async () => {
const user = await buildUser();
const document = await buildDocument({
userId: user.id,
teamId: user.teamId,
});
const res = await server.post("/api/documents.duplicate", user, {
body: {
id: document.id,
collectionId: faker.string.uuid(),
publish: true,
},
});
expect(res.status).toEqual(403);
});
it("should duplicate a document with fullWidth property", async () => {
const user = await buildUser();
const document = await buildDocument({
+1 -1
View File
@@ -1580,7 +1580,7 @@ router.post(
// The copy is created in the destination collection, so create permission
// is required there rather than on the source.
if (collection) {
if (collectionId || collection) {
authorize(user, "createDocument", collection);
}
}