Skip to content

Commit

Permalink
#263 fix role name
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Sep 5, 2017
1 parent 5553200 commit 106842f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions thehive-backend/app/controllers/UserCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ class UserCtrl @Inject() (
}

@Timed
def getKey(id: String): Action[AnyContent] = authenticated(Roles.admin).async { implicit request =>
def getKey(id: String): Action[AnyContent] = authenticated(Roles.admin).async { implicit request
authSrv.getKey(id).map(Ok(_))
}

@Timed
def renewKey(id: String): Action[AnyContent] = authenticated(Roles.admin).async { implicit request =>
def renewKey(id: String): Action[AnyContent] = authenticated(Roles.admin).async { implicit request
authSrv.renewKey(id).map(Ok(_))
}
}
18 changes: 9 additions & 9 deletions thehive-backend/app/models/Roles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import org.elastic4play.models.AttributeFormat
import org.elastic4play.services.Role

object Roles {
object read extends Role("read")
object write extends Role("write")
object admin extends Role("admin")
object alert extends Role("alert")
val roles = read :: write :: admin :: alert :: Nil

val roleNames = roles.map(_.name)
def isValid(roleName: String) = roleNames.contains(roleName)
def withName(roleName: String) = roles.find(_.name == roleName)
object read extends Role("READ")
object write extends Role("WRITE")
object admin extends Role("ADMIN")
object alert extends Role("ALERT")
val roles: List[Role] = read :: write :: admin :: alert :: Nil

val roleNames: List[String] = roles.map(_.name)
def isValid(roleName: String): Boolean = roleNames.contains(roleName)
def withName(roleName: String): Option[Role] = roles.find(_.name == roleName)
}

object RoleAttributeFormat extends AttributeFormat[Role]("role") {
Expand Down

0 comments on commit 106842f

Please sign in to comment.