Skip to content
Snippets Groups Projects
Commit d3dabdd5 authored by Sebastian's avatar Sebastian
Browse files

feat(component-invite): fix bugs

parent 148ce617
No related branches found
No related tags found
No related merge requests found
...@@ -43,7 +43,7 @@ module.exports = models => async (req, res) => { ...@@ -43,7 +43,7 @@ module.exports = models => async (req, res) => {
} }
await inviteHelper.revokeInvitation(user, collectionId, role) await inviteHelper.revokeInvitation(user, collectionId, role)
await teamHelper.removeTeamMember(team.id, userId, models.Team) await teamHelper.removeTeamMember(team.id, userId, models.Team)
user.teams = user.teams.filter(userTeam => team.id !== userTeam.id) user.teams = user.teams.filter(userTeamId => team.id !== userTeamId)
await user.save() await user.save()
await collectionHelper.removeAssignedPeople(collection, user.email) await collectionHelper.removeAssignedPeople(collection, user.email)
try { try {
......
...@@ -2,6 +2,7 @@ const logger = require('@pubsweet/logger') ...@@ -2,6 +2,7 @@ const logger = require('@pubsweet/logger')
const helpers = require('../helpers/helpers') const helpers = require('../helpers/helpers')
const teamHelper = require('../helpers/Team') const teamHelper = require('../helpers/Team')
const mailService = require('pubsweet-component-mail-service') const mailService = require('pubsweet-component-mail-service')
const collectionHelper = require('../helpers/Collection')
module.exports = models => async (req, res) => { module.exports = models => async (req, res) => {
const { type, accept } = req.body const { type, accept } = req.body
...@@ -63,6 +64,10 @@ module.exports = models => async (req, res) => { ...@@ -63,6 +64,10 @@ module.exports = models => async (req, res) => {
user.id, user.id,
models.Team, models.Team,
) )
user.teams = user.teams.filter(
userTeamId => matchingInvitation.teamId !== userTeamId,
)
await collectionHelper.removeAssignedPeople(collection, user.email)
const { reason } = req.body const { reason } = req.body
if (reason !== undefined) { if (reason !== undefined) {
matchingInvitation.reason = reason matchingInvitation.reason = reason
......
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