Skip to content

Commit

Permalink
#1316 Set new permissions when user switch of organisation
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jul 20, 2020
1 parent 5ce8607 commit 7d4aa7d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion thehive/app/org/thp/thehive/controllers/v1/UserCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ class UserCtrl @Inject() (
.current
.richUserWithCustomRenderer(request.organisation, _.organisationWithRole.map(_.asScala.toSeq))
.getOrFail("User")
.map(user => Results.Ok(user.toJson).withHeaders("X-Organisation" -> request.organisation))
.map(user =>
Results
.Ok(user.toJson)
.withHeaders("X-Organisation" -> request.organisation)
.withHeaders("X-Permissions" -> user._1.permissions.mkString(","))
)
}

def create: Action[AnyContent] =
Expand Down
2 changes: 1 addition & 1 deletion thehive/app/org/thp/thehive/services/LocalUserSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LocalUserSrv @Inject() (
userSteps
.getAuthContext(requestId, Organisation.administration.name)
.headOption()
.map(_.changeOrganisation(org))
.map(authContext => authContext.changeOrganisation(org, authContext.permissions))
}
}
.fold[Try[AuthContext]](Failure(AuthenticationError("Authentication failure")))(Success.apply)
Expand Down

0 comments on commit 7d4aa7d

Please sign in to comment.