Handle non-existent shareId

This commit is contained in:
Tom Moor
2018-05-26 11:23:21 -07:00
parent 0d7c943bcd
commit 6662e2666d
2 changed files with 10 additions and 0 deletions

View File

@ -174,6 +174,9 @@ router.post('documents.info', auth({ required: false }), async ctx => {
},
],
});
if (!share) {
throw new InvalidRequestError('Document could not be found for shareId');
}
document = share.document;
} else {
document = await Document.findById(id);

View File

@ -73,6 +73,13 @@ describe('#documents.info', async () => {
expect(body.data.createdBy.id).toEqual(user.id);
expect(body.data.updatedBy.id).toEqual(user.id);
});
it('should require a valid shareId', async () => {
const res = await server.post('/api/documents.info', {
body: { shareId: 123 },
});
expect(res.status).toEqual(400);
});
});
describe('#documents.list', async () => {