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

feat(component-invite): remove team from user on revoke

parent ab245749
No related branches found
No related tags found
No related merge requests found
......@@ -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()
}
......
......@@ -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(
......
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