Filter private info from public shares

This commit is contained in:
Tom Moor
2018-05-23 23:59:00 -07:00
parent 7eea1a90af
commit e538df0df3
8 changed files with 42 additions and 39 deletions

View File

@@ -161,7 +161,9 @@ router.post('documents.info', auth({ required: false }), async ctx => {
const { id, shareId } = ctx.body;
ctx.assertPresent(id || shareId, 'id or shareId is required');
const isPublic = !!shareId;
let document;
if (shareId) {
const share = await Share.findById(shareId, {
include: [
@@ -172,8 +174,6 @@ router.post('documents.info', auth({ required: false }), async ctx => {
},
],
});
// TODO: REMOVE COLLECTION AND COLLABORATOR INFO
document = share.document;
} else {
document = await Document.findById(id);
@@ -181,7 +181,7 @@ router.post('documents.info', auth({ required: false }), async ctx => {
}
ctx.body = {
data: await presentDocument(ctx, document),
data: await presentDocument(ctx, document, { isPublic }),
};
});

View File

@@ -52,14 +52,14 @@ router.post('shares.create', auth(), async ctx => {
const document = await Document.findById(id);
authorize(user, 'share', document);
const [share, created] = await Share.findOrCreate({
const [share] = await Share.findOrCreate({
where: {
documentId: document.id,
userId: user.id,
teamId: user.teamId,
},
});
console.log('created', created);
share.user = user;
share.document = document;