diff --git a/knockoutwhistfrontend b/knockoutwhistfrontend index 352b7fd..92a7bc0 160000 --- a/knockoutwhistfrontend +++ b/knockoutwhistfrontend @@ -1 +1 @@ -Subproject commit 352b7fd3ff689dea1693ae1059634a6768107211 +Subproject commit 92a7bc05866b77053ebb1d074ad207be8348f9d6 diff --git a/knockoutwhistweb/app/controllers/MainMenuController.scala b/knockoutwhistweb/app/controllers/MainMenuController.scala index ca87f87..8dd6cfe 100644 --- a/knockoutwhistweb/app/controllers/MainMenuController.scala +++ b/knockoutwhistweb/app/controllers/MainMenuController.scala @@ -55,32 +55,21 @@ class MainMenuController @Inject()( } - def joinGame(): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] => - val jsonBody = request.body.asJson - val gameId: Option[String] = jsonBody.flatMap { jsValue => - (jsValue \ "gameId").asOpt[String] - } - if (gameId.isDefined) { - val game = PodManager.getGame(gameId.get) - game match { - case Some(g) => - g.addUser(request.user) - Ok(Json.obj( - "status" -> "success", - "redirectUrl" -> routes.IngameController.game(g.id).url, - "content" -> IngameController.returnInnerHTML(g, g.logic.getCurrentState, request.user).toString - )) - case None => - NotFound(Json.obj( - "status" -> "failure", - "errorMessage" -> "No Game found" - )) - } - } else { - BadRequest(Json.obj( - "status" -> "failure", - "errorMessage" -> "Invalid form submission" - )) + def joinGame(gameId: String): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] => + val game = PodManager.getGame(gameId) + game match { + case Some(g) => + g.addUser(request.user) + Ok(Json.obj( + "status" -> "success", + "redirectUrl" -> routes.IngameController.game(g.id).url, + "content" -> IngameController.returnInnerHTML(g, g.logic.getCurrentState, request.user).toString + )) + case None => + NotFound(Json.obj( + "status" -> "failure", + "errorMessage" -> "No Game found" + )) } } diff --git a/knockoutwhistweb/conf/routes b/knockoutwhistweb/conf/routes index dc89fca..2fb460e 100644 --- a/knockoutwhistweb/conf/routes +++ b/knockoutwhistweb/conf/routes @@ -15,7 +15,7 @@ GET /rules controllers.MainMenuController.rules() GET /navSPA/:pType controllers.MainMenuController.navSPA(pType) POST /createGame controllers.MainMenuController.createGame() -POST /joinGame controllers.MainMenuController.joinGame() +POST /joinGame/:gameId controllers.MainMenuController.joinGame(gameId: String) # User authentication routes POST /login controllers.UserController.login_Post()