Skip to content

Commit

Permalink
#1237 Prevent a user from being in an organization more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Mar 3, 2020
1 parent 722cdd0 commit 8d26c37
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions thehive/app/org/thp/thehive/services/UserSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ class UserSrv @Inject() (configuration: Configuration, roleSrv: RoleSrv, auditSr
implicit graph: Graph,
authContext: AuthContext
): Try[RichUser] =
for {
_ <- roleSrv.create(user, organisation, profile)
richUser <- get(user).richUser(organisation.name).getOrFail()
_ <- auditSrv.user.create(user, richUser.toJson)
} yield richUser
get(user).richUser(organisation.name).getOrFail().orElse {
for {
_ <- roleSrv.create(user, organisation, profile)
richUser <- get(user).richUser(organisation.name).getOrFail()
_ <- auditSrv.user.create(user, richUser.toJson)
} yield richUser
}

def addOrCreateUser(user: User, avatar: Option[FFile], organisation: Organisation with Entity, profile: Profile with Entity)(
implicit graph: Graph,
Expand Down

0 comments on commit 8d26c37

Please sign in to comment.