prevent challenge nastyness

by opening several challenge setups before the opponent blocks,
one could send a few challenges even after having been blocked
This commit is contained in:
Thibault Duplessis 2016-03-25 00:59:57 +07:00
parent 79eb255151
commit 6c0a9e27af

View file

@ -41,7 +41,7 @@ object Setup extends LilaController with TheftPrevention {
}
def friendForm(userId: Option[String]) = Open { implicit ctx =>
if (HTTPRequest isXhr ctx.req) {
if (HTTPRequest isXhr ctx.req)
env.forms friendFilled get("fen") flatMap { form =>
val validFen = form("fen").value flatMap ValidFen(false)
userId ?? UserRepo.named flatMap {
@ -51,7 +51,6 @@ object Setup extends LilaController with TheftPrevention {
}
}
}
}
else fuccess {
Redirect(routes.Lobby.home + "#friend")
}
@ -67,6 +66,10 @@ object Setup extends LilaController with TheftPrevention {
api = _ => fuccess(BadRequest(errorsAsJson(f)))
), {
case config => userId ?? UserRepo.byId flatMap { destUser =>
destUser ?? Challenge.restriction flatMap {
case Some(_) =>
Redirect(routes.Lobby.home + s"?user=${~userId}#friend").fuccess
case None =>
import lila.challenge.Challenge._
val challenge = lila.challenge.Challenge.make(
variant = config.variant,
@ -91,6 +94,7 @@ object Setup extends LilaController with TheftPrevention {
api = _ => Challenge showChallenge challenge)
}
}
}
)
}
}