fix: Incorrect policy returned for parent share
This commit is contained in:
parent
dcec3dd4ec
commit
7bc7d7cd6b
|
@ -12,7 +12,7 @@ allow(User, "read", Share, (user, share) => {
|
|||
allow(User, "update", Share, (user, share) => {
|
||||
if (user.isViewer) return false;
|
||||
|
||||
// only the user who can share the document publicaly can update the share.
|
||||
// only the user who can share the document publicly can update the share.
|
||||
if (cannot(user, "share", share.document)) return false;
|
||||
return user.teamId === share.teamId;
|
||||
});
|
||||
|
|
|
@ -62,7 +62,9 @@ router.post("shares.info", auth(), async (ctx) => {
|
|||
const parentIds = document?.collection?.getDocumentParents(documentId);
|
||||
|
||||
const parentShare = parentIds
|
||||
? await Share.findOne({
|
||||
? await Share.scope({
|
||||
method: ["withCollection", user.id],
|
||||
}).findOne({
|
||||
where: {
|
||||
documentId: parentIds,
|
||||
teamId: user.teamId,
|
||||
|
|
|
@ -424,6 +424,8 @@ describe("#shares.info", () => {
|
|||
expect(body.data.shares[0].documentId).toBe(document.id);
|
||||
expect(body.data.shares[0].published).toBe(true);
|
||||
expect(body.data.shares[0].includeChildDocuments).toBe(true);
|
||||
expect(body.policies.length).toBe(1);
|
||||
expect(body.policies[0].abilities.update).toBe(true);
|
||||
});
|
||||
|
||||
it("should not return share for parent document with includeChildDocuments=false", async () => {
|
||||
|
|
Reference in New Issue