Skip to content

Commit

Permalink
make it possible again to kick user out of organization team (#2801)
Browse files Browse the repository at this point in the history
  • Loading branch information
fm3 authored Jun 28, 2018
1 parent fb20ea8 commit b914934
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions app/controllers/UserController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -211,26 +211,12 @@ class UserController @Inject()(val messagesApi: MessagesApi)
teamsWithUpdate <- Fox.filter(assignedMembershipWTeams)(t => issuingUser.isTeamManagerOrAdminOf(t._1._id))
_ <- ensureProperTeamAdministration(user, teamsWithUpdate)
trimmedExperiences = experiences.map { case (key, value) => key.trim -> value }
updatedTeams <- ensureOrganizationTeamIsPresent(user, teamsWithUpdate.map(_._1) ++ teamsWithoutUpdate)
updatedTeams = teamsWithUpdate.map(_._1) ++ teamsWithoutUpdate
updatedUser <- UserService.update(user, firstName.trim, lastName.trim, email, isActive, isAdmin, updatedTeams, trimmedExperiences)
} yield {
Ok(User.userPublicWrites(request.identity).writes(updatedUser))
}
}
}

def ensureOrganizationTeamIsPresent(user: User, updatedTeams: List[TeamMembership]) = {
for {
organization <- OrganizationDAO.findOneByName(user.organization)(GlobalAccessContext)
orgTeam = organization._organizationTeam
} yield {
if (updatedTeams.exists(t => t._id == orgTeam))
updatedTeams
else
user.teams.find(t => t._id == orgTeam) match {
case Some(teamMembership) => teamMembership :: updatedTeams
case None => updatedTeams
}
}
}
}

0 comments on commit b914934

Please sign in to comment.