diff --git a/backend/api/documents.py b/backend/api/documents.py index 10456c5..b4000cf 100644 --- a/backend/api/documents.py +++ b/backend/api/documents.py @@ -542,9 +542,20 @@ async def get_document( raise HTTPException(404, "Document not found") doc = await session.get(Document, uid) - if doc is None or doc.user_id != current_user.id: + if doc is None: raise HTTPException(404, "Document not found") + if doc.user_id != current_user.id: + # Allow recipients of an active share to view the document + share_result = await session.execute( + select(Share).where( + Share.document_id == uid, + Share.recipient_id == current_user.id, + ) + ) + if share_result.scalar_one_or_none() is None: + raise HTTPException(404, "Document not found") + meta = await storage.get_metadata(session, doc_id) if meta is None: raise HTTPException(404, "Document not found") diff --git a/frontend/src/components/sharing/ShareModal.vue b/frontend/src/components/sharing/ShareModal.vue index 8a369bc..4b29809 100644 --- a/frontend/src/components/sharing/ShareModal.vue +++ b/frontend/src/components/sharing/ShareModal.vue @@ -28,28 +28,30 @@ -