Version 2, last updated by ca6BeAeE at 20 Jan 04:18 UTC

TestAccess is a quick and easy way to hide a menu item for some reason. For example, the following code in Boot.scala will hide a menu item unless the user is logged in and the user is a superuser; otherwise, the user will get a plan text response (alternatively, RedirectResponse or something else could have been used):

class Boot extends Logger {
  def boot {
...
    val IfSuperUser = TestAccess(() => isSuperUser)

    val entries:List[Menu] = List[Menu](
        Menu("Home") / "index",
        Menu("Admin Page")        / "admin" / "listusers" >> IfSuperUser
    )
...
  }

  def isSuperUser : Box[LiftResponse] = {
    if (User.loggedIn_? && User.currentUser.openTheBox.superUser.is)
      Empty
    else
      Full(PlainTextResponse("Unauthorized"))
  }
}