chore: change the way that share permissions are checked on child documents to use the parentId field of documents rather than the collection structure (#3294)

This commit is contained in:
Nan Yu
2022-03-28 10:18:59 -07:00
committed by GitHub
parent 3d478246bf
commit 096b35e08e
3 changed files with 6 additions and 81 deletions

View File

@@ -542,10 +542,12 @@ async function loadDocument({
// shared then includeChildDocuments must be enabled and the document must
// still be nested within the shared document
if (share.document.id !== document.id) {
if (
!share.includeChildDocuments ||
!collection.isChildDocument(share.document.id, document.id)
) {
if (!share.includeChildDocuments) {
throw AuthorizationError();
}
const childDocumentIds = await share.document.getChildDocumentIds();
if (!childDocumentIds.includes(document.id)) {
throw AuthorizationError();
}
}