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") { -