forbid tournaments to engine users

This commit is contained in:
Thibault Duplessis 2012-09-22 13:47:47 +02:00
parent 6170498e05
commit eba4c8138a
3 changed files with 32 additions and 14 deletions

View file

@ -74,6 +74,9 @@ trait LilaController
}
)
protected def NoEngine[A <: Result](a: A)(implicit ctx: Context): Result =
ctx.me.fold(_.engine, false).fold(Forbidden(views.html.site.noEngine()), a)
protected def JsonOk(map: Map[String, Any]) = Ok(toJson(map)) as JSON
protected def JsonOk(list: List[Any]) = Ok(Json generate list) as JSON

View file

@ -76,8 +76,9 @@ object Tournament extends LilaController {
version = version(tour.id),
games = games)
def join(id: String) = Auth { implicit ctx
def join(id: String) = AuthBody { implicit ctx
implicit me
NoEngine {
IOptionIORedirect(repo createdById id) { tour
api.join(tour, me).fold(
err putStrLn(err.shows) map (_ routes.Tournament.home()),
@ -85,6 +86,7 @@ object Tournament extends LilaController {
)
}
}
}
def withdraw(id: String) = Auth { implicit ctx
implicit me
@ -124,11 +126,14 @@ object Tournament extends LilaController {
def form = Auth { implicit ctx
me
NoEngine {
Ok(html.tournament.form(forms.create, forms))
}
}
def create = AuthBody { implicit ctx
implicit me
NoEngine {
IOResult {
implicit val req = ctx.body
forms.create.bindFromRequest.fold(
@ -138,6 +143,7 @@ object Tournament extends LilaController {
})
}
}
}
def websocket(id: String) = WebSocket.async[JsValue] { req
implicit val ctx = reqToCtx(req)

View file

@ -0,0 +1,9 @@
@()(implicit ctx: Context)
@site.layout(
title = "No engine area") {
<div class="content_box small_box">
Sorry, engines are not allowed in this area.
</div>
}