Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JosephMoniz/b4608c47211dbe9a3d81 to your computer and use it in GitHub Desktop.
Save JosephMoniz/b4608c47211dbe9a3d81 to your computer and use it in GitHub Desktop.
Authentication middleware
final case class AuthenticatedOnlyMiddleware() extends Middleware {
def intercept(next: Controller) = AdhocController { request =>
request
.session
.get("user")
.map(_ => next.action(request))
.getOrElse(Found("").withHeader(Location("/login")))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment