Skip to content

Commit

Permalink
#1501 Fix admin rights
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Oct 22, 2020
1 parent 86a929f commit f90c4ef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions thehive/app/org/thp/thehive/services/UserSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,17 @@ object UserOps {
.project(
_.byValue(_.login)
.byValue(_.name)
.by(_.role.filter(_.organisation.get(organisationName)).profile.fold)
.by(_.profile(organisationName).fold)
.by(_.organisations.get(organisationName).value(_.name).limit(1).fold)
.by(_.profile(EntityName(Organisation.administration.name)).fold)
)
.domainMap {
case (userId, userName, profile, org) =>
case (userId, userName, profile, org, adminProfile) =>
val scope =
if (org.contains(Organisation.administration.name)) "admin"
else "organisation"
val permissions = Permissions.forScope(scope) & profile.headOption.fold(Set.empty[Permission])(_.permissions)
val permissions =
Permissions.forScope(scope) & profile.headOption.orElse(adminProfile.headOption).fold(Set.empty[Permission])(_.permissions)
AuthContextImpl(userId, userName, organisationName, requestId, permissions)
}

Expand Down

0 comments on commit f90c4ef

Please sign in to comment.