Skip to content

Instantly share code, notes, and snippets.

@stephanos
Created May 14, 2012 16:26
Show Gist options
  • Select an option

  • Save stephanos/2694905 to your computer and use it in GitHub Desktop.

Select an option

Save stephanos/2694905 to your computer and use it in GitHub Desktop.
play onRouteRequest
override def onRouteRequest(req: RequestHeader): Option[Action[_]] =
super.onRouteRequest(req).map {
case action: Action[_] =>
currentUserId(req) match {
case None =>
req.path match {
case p if isRestrictedPath(p) => // requires login
Authenticated(action)
case p if isEncryptedWhenLoggedOut(p) => // required HTTPS for user/
Encrypted(action)
case _ =>
action
}
case _ =>
req.path match {
case p if isAdminPath(p) => // require HTTPS and ADMIN
Encrypted(Admin(action))
case p if isHiddenForLoggedInUsers(p) =>
Action(redirectToHttps(req, "/"))
case _ =>
Encrypted(action)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment