diff --git a/knockoutwhistweb/app/controllers/IngameController.scala b/knockoutwhistweb/app/controllers/IngameController.scala index ccf12c2..02544ee 100644 --- a/knockoutwhistweb/app/controllers/IngameController.scala +++ b/knockoutwhistweb/app/controllers/IngameController.scala @@ -15,61 +15,11 @@ import javax.inject.* @Singleton class IngameController @Inject()( val controllerComponents: ControllerComponents, - val sessionManager: SessionManager, - val userManager: UserManager, val authAction: AuthAction ) extends BaseController { - - // Pass the request-handling function directly to authAction (no nested Action) + def mainMenu(): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] => Ok("Main Menu for user: " + request.user.name) } - def login(): Action[AnyContent] = { - Action { implicit request => - val session = request.cookies.get("sessionId") - if (session.isDefined) { - val possibleUser = sessionManager.getUserBySession(session.get.value) - if (possibleUser.isDefined) { - Redirect("/mainmenu") - } else { - Ok(views.html.login()) - } - } else { - Ok(views.html.login()) - } - } - } - - def login_Post(): Action[AnyContent] = { - Action { implicit request => - val postData = request.body.asFormUrlEncoded - if (postData.isDefined) { - // Extract username and password from form data - val username = postData.get.get("username").flatMap(_.headOption).getOrElse("") - val password = postData.get.get("password").flatMap(_.headOption).getOrElse("") - val possibleUser = userManager.authenticate(username, password) - if (possibleUser.isDefined) { - Redirect("/mainmenu").withCookies( - Cookie("sessionId", sessionManager.createSession(possibleUser.get)) - ) - } else { - println("Failed login attempt for user: " + username) - Unauthorized("Invalid username or password") - } - } else { - BadRequest("Invalid form submission") - } - } - } - - // Pass the request-handling function directly to authAction (no nested Action) - def logout(): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] => - val sessionCookie = request.cookies.get("sessionId") - if (sessionCookie.isDefined) { - sessionManager.invalidateSession(sessionCookie.get.value) - } - NoContent.discardingCookies(DiscardingCookie("sessionId")) - } - } \ No newline at end of file diff --git a/knockoutwhistweb/app/util/WebUIUtils.scala b/knockoutwhistweb/app/util/WebUIUtils.scala index 84e0558..b905462 100644 --- a/knockoutwhistweb/app/util/WebUIUtils.scala +++ b/knockoutwhistweb/app/util/WebUIUtils.scala @@ -29,6 +29,6 @@ object WebUIUtils { case Three => "3" case Two => "2" } - views.html.output.card.apply(f"images/cards/$cv$s.png")(card.toString) + views.html.render.card.apply(f"images/cards/$cv$s.png")(card.toString) } } diff --git a/knockoutwhistweb/app/views/index.scala.html b/knockoutwhistweb/app/views/index.scala.html deleted file mode 100644 index d4fdd74..0000000 --- a/knockoutwhistweb/app/views/index.scala.html +++ /dev/null @@ -1,3 +0,0 @@ -@main("Welcome to Play") { -

Welcome to Play!

-} diff --git a/knockoutwhistweb/app/views/ingame.scala.html b/knockoutwhistweb/app/views/ingame/ingame.scala.html similarity index 93% rename from knockoutwhistweb/app/views/ingame.scala.html rename to knockoutwhistweb/app/views/ingame/ingame.scala.html index 23eaf99..7ce7c26 100644 --- a/knockoutwhistweb/app/views/ingame.scala.html +++ b/knockoutwhistweb/app/views/ingame/ingame.scala.html @@ -17,7 +17,7 @@ @if(logic.getCurrentTrick.get.firstCard.isDefined) { @util.WebUIUtils.cardtoImage(logic.getCurrentTrick.get.firstCard.get) } else { - @views.html.output.card.apply("images/cards/1B.png")("Blank Card") + @views.html.render.card.apply("../../../public/images/cards/1B.png")("Blank Card") } diff --git a/knockoutwhistweb/app/views/selecttrump.scala.html b/knockoutwhistweb/app/views/ingame/selecttrump.scala.html similarity index 100% rename from knockoutwhistweb/app/views/selecttrump.scala.html rename to knockoutwhistweb/app/views/ingame/selecttrump.scala.html diff --git a/knockoutwhistweb/app/views/tie.scala.html b/knockoutwhistweb/app/views/ingame/tie.scala.html similarity index 100% rename from knockoutwhistweb/app/views/tie.scala.html rename to knockoutwhistweb/app/views/ingame/tie.scala.html diff --git a/knockoutwhistweb/app/views/output/card.scala.html b/knockoutwhistweb/app/views/render/card.scala.html similarity index 100% rename from knockoutwhistweb/app/views/output/card.scala.html rename to knockoutwhistweb/app/views/render/card.scala.html diff --git a/knockoutwhistweb/app/views/output/text.scala.html b/knockoutwhistweb/app/views/render/text.scala.html similarity index 100% rename from knockoutwhistweb/app/views/output/text.scala.html rename to knockoutwhistweb/app/views/render/text.scala.html diff --git a/knockoutwhistweb/app/views/tui.scala.html b/knockoutwhistweb/app/views/tui.scala.html deleted file mode 100644 index 8d8cc04..0000000 --- a/knockoutwhistweb/app/views/tui.scala.html +++ /dev/null @@ -1,10 +0,0 @@ -@(toRender: List[Html]) - -@main("Tui") { -
- @for(line <- toRender) { - @line - } -
-} -