diff --git a/packages/component-invite/src/helpers/Team.js b/packages/component-invite/src/helpers/Team.js index 9a9319e25d942c33b65c0a13053a1e0868871989..9c8d5175a15e0b50c876590394bcdffb0514cf52 100644 --- a/packages/component-invite/src/helpers/Team.js +++ b/packages/component-invite/src/helpers/Team.js @@ -118,12 +118,10 @@ const getMatchingTeams = (teams, TeamModel, collectionId, role) => .filter(Boolean) const removeTeamMember = async (teamId, userId, TeamModel) => { - let team = await TeamModel.find(teamId) + const team = await TeamModel.find(teamId) const members = team.members.filter(member => member !== userId) team.members = members - team = await team.updateProperties(team) - await team.save() } diff --git a/packages/component-invite/src/routes/deleteInvitation.js b/packages/component-invite/src/routes/deleteInvitation.js index 9062262829d0c6ff875bde722f6540feedb84758..59dd9905e99046314d541384a2d9b2a37f29a406 100644 --- a/packages/component-invite/src/routes/deleteInvitation.js +++ b/packages/component-invite/src/routes/deleteInvitation.js @@ -28,7 +28,7 @@ module.exports = models => async (req, res) => { const { collectionId, userId } = req.params try { const collection = await models.Collection.find(collectionId) - let user = await models.User.find(userId) + const user = await models.User.find(userId) const team = await teamHelper.getTeamByGroupAndCollection( collectionId, role, @@ -42,8 +42,9 @@ module.exports = models => async (req, res) => { return } await inviteHelper.revokeInvitation(user, collectionId, role) - user = await models.User.find(userId) await teamHelper.removeTeamMember(team.id, userId, models.Team) + user.teams = user.teams.filter(userTeam => team.id !== userTeam.id) + await user.save() await collectionHelper.removeAssignedPeople(collection, user.email) try { await mailService.setupRevokeInvitationEmail(