Skip to content

Commit

Permalink
Merge pull request #572 from SpongePowered/fix/groups
Browse files Browse the repository at this point in the history
don't require all groups to exist in RoleTypes
  • Loading branch information
progwml6 authored Jul 15, 2018
2 parents 390927d + 9c08af3 commit a821a9c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/ApiController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ final class ApiController @Inject()(api: OreRestfulApi,
if (groups.trim == "")
Set.empty
else
groups.split(",").map(group => RoleTypes.withInternalName(group)).toSet[RoleType]
groups.split(",").flatMap(group => RoleTypes.withInternalName(group)).toSet[RoleType]
)
}

Expand Down
6 changes: 1 addition & 5 deletions app/ore/permission/role/RoleTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@ object RoleTypes extends Enumeration {
* @param internalName Internal name
* @return UserRole with specified internal name
*/
def withInternalName(internalName: String): RoleType = this.values.find(_.internalName == internalName).getOrElse {
// Throw an exception instead of returning an Option to match Enumeration
// behavior
throw new NoSuchElementException
}
def withInternalName(internalName: String): Option[RoleType] = this.values.find(_.internalName == internalName).map(value => convert(value))

/**
* Represents a User role.
Expand Down

0 comments on commit a821a9c

Please sign in to comment.