Skip to content

Instantly share code, notes, and snippets.

@ufasoli
Created March 30, 2014 15:58
Show Gist options
  • Select an option

  • Save ufasoli/9874880 to your computer and use it in GitHub Desktop.

Select an option

Save ufasoli/9874880 to your computer and use it in GitHub Desktop.
object CookieActionWrapper extends Controller {
val emailCookie = "email"
def ActionWrapper[A](action: Action[A]) = Action.async(action.parser) {
implicit request =>
val cookie = request.cookies.get(emailCookie)
// user needs to register before answering to any question
if (cookie == None) {
Future(BadRequest(views.html.errors.not_registered()))
}
else {
action(request)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment