Merge pull request #288 from jorilallo/jori/move-tweaks

Refactored document move
This commit is contained in:
Jori Lallo
2017-10-07 16:07:12 -07:00
committed by GitHub
6 changed files with 241 additions and 159 deletions

View File

@@ -264,7 +264,7 @@ router.post('documents.move', auth(), async ctx => {
// Set parent document
if (parentDocument) {
const parent = await Document.findById(parentDocument);
if (parent.atlasId !== document.atlasId)
if (!parent || parent.atlasId !== document.atlasId)
throw httpErrors.BadRequest(
'Invalid parentDocument (must be same collection)'
);