Skip to content
Snippets Groups Projects
Commit 2d0fd863 authored by Andrei Cioromila's avatar Andrei Cioromila
Browse files

fix(invite): Return error when inviting reviewers on older manuscript versions

parent 5f7b142d
No related branches found
No related tags found
2 merge requests!136Sprint 22 features (updates),!127Hin 1082
...@@ -11,6 +11,8 @@ const { ...@@ -11,6 +11,8 @@ const {
const emailInvitations = require('./emails/invitations') const emailInvitations = require('./emails/invitations')
const { last } = require('lodash')
module.exports = models => async (req, res) => { module.exports = models => async (req, res) => {
const { email, role } = req.body const { email, role } = req.body
...@@ -40,6 +42,10 @@ module.exports = models => async (req, res) => { ...@@ -40,6 +42,10 @@ module.exports = models => async (req, res) => {
return res.status(400).json({ return res.status(400).json({
error: `Fragment ${fragmentId} does not match collection ${collectionId}.`, error: `Fragment ${fragmentId} does not match collection ${collectionId}.`,
}) })
if (last(collection.fragments) !== fragmentId)
return res.status(400).json({
error: `Fragment ${fragmentId} is an older version.`,
})
fragment = await models.Fragment.find(fragmentId) fragment = await models.Fragment.find(fragmentId)
} catch (e) { } catch (e) {
const notFoundError = await services.handleNotFoundError(e, 'item') const notFoundError = await services.handleNotFoundError(e, 'item')
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment