fix: Moving document in private collection returns incorrect policies (#1969)

* fix: Return no policies when collection doesn't change
fix: Return correct policies when it does change

* test
This commit is contained in:
Tom Moor
2021-03-19 08:01:51 -07:00
committed by GitHub
parent 7891a8ee8b
commit ad8c08497c
4 changed files with 12 additions and 4 deletions

View File

@@ -1047,7 +1047,7 @@ router.post("documents.move", auth(), async (ctx) => {
authorize(user, "update", parent);
}
const { documents, collections } = await documentMover({
const { documents, collections, collectionChanged } = await documentMover({
user,
document,
collectionId,
@@ -1065,7 +1065,7 @@ router.post("documents.move", auth(), async (ctx) => {
collections.map((collection) => presentCollection(collection))
),
},
policies: presentPolicies(user, documents),
policies: collectionChanged ? presentPolicies(user, documents) : [],
};
});

View File

@@ -1325,6 +1325,7 @@ describe("#documents.move", () => {
const body = await res.json();
expect(res.status).toEqual(200);
expect(body.data.documents[0].collectionId).toEqual(collection.id);
expect(body.policies[0].abilities.move).toEqual(true);
});
it("should not allow moving the document to a collection the user cannot access", async () => {