diff --git a/config/chat/routing.yml b/config/chat/routing.yml new file mode 100644 index 000000000..76621c3ba --- /dev/null +++ b/config/chat/routing.yml @@ -0,0 +1,11 @@ +chat_write_message: + path: /api/chat/chats/{chatId}/write-message + methods: [POST] + controller: chat.chat-controller::writeMessageAction + defaults: { _format: json } + +chat_messages: + path: /api/chat/chats/{chatId}/messages + methods: [GET] + controller: chat.chat-controller::messagesAction + defaults: { _format: json } diff --git a/config/chat/services/controller.yml b/config/chat/services/controller.yml new file mode 100644 index 000000000..ac6ff1fa5 --- /dev/null +++ b/config/chat/services/controller.yml @@ -0,0 +1,5 @@ +services: + chat.chat-controller: + class: Gaming\Chat\Presentation\Http\ChatController + arguments: ['@chat.command-bus', '@chat.query-bus', '@web-interface.security', '@gaming.usernames'] + tags: ['controller.service_arguments'] diff --git a/config/connect-four/routing.yml b/config/connect-four/routing.yml index ecf8448f7..84c1c42ee 100644 --- a/config/connect-four/routing.yml +++ b/config/connect-four/routing.yml @@ -17,3 +17,27 @@ connect_four_challenge: path: /challenge/{id} methods: [GET] controller: connect-four.challenge-controller::showAction + +connect_four_abort_game: + path: /api/connect-four/games/{gameId}/abort + methods: [POST] + controller: connect-four.game-controller::abortAction + defaults: { _format: json } + +connect_four_resign_game: + path: /api/connect-four/games/{gameId}/resign + methods: [POST] + controller: connect-four.game-controller::resignAction + defaults: { _format: json } + +connect_four_join_game: + path: /api/connect-four/games/{gameId}/join + methods: [POST] + controller: connect-four.game-controller::joinAction + defaults: { _format: json } + +connect_four_move_game: + path: /api/connect-four/games/{gameId}/move + methods: [POST] + controller: connect-four.game-controller::moveAction + defaults: { _format: json } diff --git a/config/connect-four/services/controller.yml b/config/connect-four/services/controller.yml index 08e8a3639..9baf0e507 100644 --- a/config/connect-four/services/controller.yml +++ b/config/connect-four/services/controller.yml @@ -14,3 +14,8 @@ services: - '@gaming.usernames' calls: [[setContainer, ['@Psr\Container\ContainerInterface']]] tags: ['controller.service_arguments', 'container.service_subscriber'] + + connect-four.game-controller: + class: Gaming\ConnectFour\Port\Adapter\Http\GameController + arguments: ['@connect-four.command-bus', '@web-interface.security'] + tags: ['controller.service_arguments'] diff --git a/config/identity/config.yml b/config/identity/config.yml index ac027a78e..cdd80a0de 100644 --- a/config/identity/config.yml +++ b/config/identity/config.yml @@ -10,6 +10,9 @@ gaming_platform_bus: identity_command: ~ identity_query: ~ +twig: + paths: { '%kernel.project_dir%/src/Identity/Port/Adapter/Http/View': identity } + doctrine: dbal: connections: diff --git a/config/identity/routing.yml b/config/identity/routing.yml new file mode 100644 index 000000000..d90e5b12c --- /dev/null +++ b/config/identity/routing.yml @@ -0,0 +1,31 @@ +_symfony_logout: + resource: security.route_loader.logout + type: service + +identity_signup: + path: /signup + methods: [GET, POST] + controller: identity.signup-controller::indexAction + +identity_signup_verify_email: + path: /signup/verify-email + methods: [GET] + controller: identity.signup-controller::verifyEmailAction + +identity_signup_confirm: + path: /signup/confirm + methods: [GET, POST] + controller: identity.signup-controller::confirmAction + +identity_login: + path: /login + methods: [GET, POST] + controller: identity.login-controller::indexAction + +identity_login_check_inbox: + path: /login/check-inbox + methods: [GET] + controller: identity.login-controller::checkInboxAction + +identity_login_check: + path: /login/check diff --git a/config/identity/services/controller.yml b/config/identity/services/controller.yml new file mode 100644 index 000000000..4ef04cc76 --- /dev/null +++ b/config/identity/services/controller.yml @@ -0,0 +1,21 @@ +services: + identity.signup-controller: + class: Gaming\Identity\Port\Adapter\Http\SignupController + arguments: + - '@uri_signer' + - '@web-interface.security' + - '@identity.command-bus' + - '@gaming.form-violation-mapper' + calls: [[setContainer, ['@Psr\Container\ContainerInterface']]] + tags: ['controller.service_arguments', 'container.service_subscriber'] + + identity.login-controller: + class: Gaming\Identity\Port\Adapter\Http\LoginController + arguments: + - '@security.authentication_utils' + - '@security.authenticator.firewall_aware_login_link_handler' + - '@uri_signer' + - '@identity.query-bus' + - '@gaming.form-violation-mapper' + calls: [[setContainer, ['@Psr\Container\ContainerInterface']]] + tags: ['controller.service_arguments', 'container.service_subscriber'] diff --git a/config/web-interface/config.yml b/config/web-interface/config.yml index 7d3f5ae4a..1b1c03a15 100644 --- a/config/web-interface/config.yml +++ b/config/web-interface/config.yml @@ -24,7 +24,7 @@ security: pattern: ^/ lazy: true login_link: - check_route: login_check + check_route: identity_login_check signature_properties: ['userIdentifier'] logout: path: /logout diff --git a/config/web-interface/routing.yml b/config/web-interface/routing.yml index f352c38f0..c4074bc91 100644 --- a/config/web-interface/routing.yml +++ b/config/web-interface/routing.yml @@ -1,11 +1,3 @@ -_symfony_logout: - resource: security.route_loader.logout - type: service - -############################################### -# Pages # -############################################### - lobby: path: / methods: [GET] @@ -26,80 +18,8 @@ game: methods: [GET] controller: web-interface.page-controller::gameAction -signup: - path: /signup - methods: [GET, POST] - controller: web-interface.signup-controller::indexAction - -signup_verify_email: - path: /signup/verify-email - methods: [GET] - controller: web-interface.signup-controller::verifyEmailAction - -signup_confirm: - path: /signup/confirm - methods: [GET, POST] - controller: web-interface.signup-controller::confirmAction - -login: - path: /login - methods: [GET, POST] - controller: web-interface.login-controller::indexAction - -login_check_inbox: - path: /login/check-inbox - methods: [GET] - controller: web-interface.login-controller::checkInboxAction - -login_check: - path: /login/check - server_time: path: /api/server-time methods: [GET] controller: web-interface.server-time-controller::serverTimeAction defaults: { _format: json } - -############################################### -# Chat Service # -############################################### - -write_message: - path: /api/chat/chats/{chatId}/write-message - methods: [POST] - controller: web-interface.chat-controller::writeMessageAction - defaults: { _format: json } - -messages: - path: /api/chat/chats/{chatId}/messages - methods: [GET] - controller: web-interface.chat-controller::messagesAction - defaults: { _format: json } - -############################################### -# Connect Four Service # -############################################### - -abort: - path: /api/connect-four/games/{gameId}/abort - methods: [POST] - controller: web-interface.connect-four-controller::abortAction - defaults: { _format: json } - -resign: - path: /api/connect-four/games/{gameId}/resign - methods: [POST] - controller: web-interface.connect-four-controller::resignAction - defaults: { _format: json } - -join: - path: /api/connect-four/games/{gameId}/join - methods: [POST] - controller: web-interface.connect-four-controller::joinAction - defaults: { _format: json } - -move: - path: /api/connect-four/games/{gameId}/move - methods: [POST] - controller: web-interface.connect-four-controller::moveAction - defaults: { _format: json } diff --git a/config/web-interface/services/controller.yml b/config/web-interface/services/controller.yml index c5f5abc21..959aa7295 100644 --- a/config/web-interface/services/controller.yml +++ b/config/web-interface/services/controller.yml @@ -5,37 +5,6 @@ services: calls: [[setContainer, ['@Psr\Container\ContainerInterface']]] tags: ['controller.service_arguments', 'container.service_subscriber'] - web-interface.signup-controller: - class: Gaming\WebInterface\Presentation\Http\SignupController - arguments: - - '@uri_signer' - - '@web-interface.security' - - '@identity.command-bus' - - '@gaming.form-violation-mapper' - calls: [[setContainer, ['@Psr\Container\ContainerInterface']]] - tags: ['controller.service_arguments', 'container.service_subscriber'] - - web-interface.login-controller: - class: Gaming\WebInterface\Presentation\Http\LoginController - arguments: - - '@security.authentication_utils' - - '@security.authenticator.firewall_aware_login_link_handler' - - '@uri_signer' - - '@identity.query-bus' - - '@gaming.form-violation-mapper' - calls: [[setContainer, ['@Psr\Container\ContainerInterface']]] - tags: ['controller.service_arguments', 'container.service_subscriber'] - - web-interface.chat-controller: - class: Gaming\WebInterface\Presentation\Http\ChatController - arguments: ['@chat.command-bus', '@chat.query-bus', '@web-interface.security', '@gaming.usernames'] - tags: ['controller.service_arguments'] - - web-interface.connect-four-controller: - class: Gaming\WebInterface\Presentation\Http\ConnectFourController - arguments: ['@connect-four.command-bus', '@web-interface.security'] - tags: ['controller.service_arguments'] - web-interface.server-time-controller: class: Gaming\WebInterface\Presentation\Http\ServerTimeController tags: ['controller.service_arguments'] diff --git a/src/WebInterface/Presentation/Http/ChatController.php b/src/Chat/Presentation/Http/ChatController.php similarity index 96% rename from src/WebInterface/Presentation/Http/ChatController.php rename to src/Chat/Presentation/Http/ChatController.php index df808baab..203a2f9fb 100644 --- a/src/WebInterface/Presentation/Http/ChatController.php +++ b/src/Chat/Presentation/Http/ChatController.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Gaming\WebInterface\Presentation\Http; +namespace Gaming\Chat\Presentation\Http; use Gaming\Chat\Application\Command\WriteMessageCommand; use Gaming\Chat\Application\Query\MessagesQuery; diff --git a/src/WebInterface/Presentation/Http/ConnectFourController.php b/src/ConnectFour/Port/Adapter/Http/GameController.php similarity index 95% rename from src/WebInterface/Presentation/Http/ConnectFourController.php rename to src/ConnectFour/Port/Adapter/Http/GameController.php index 79359c01a..7f1e53e66 100644 --- a/src/WebInterface/Presentation/Http/ConnectFourController.php +++ b/src/ConnectFour/Port/Adapter/Http/GameController.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Gaming\WebInterface\Presentation\Http; +namespace Gaming\ConnectFour\Port\Adapter\Http; use Gaming\Common\Bus\Bus; use Gaming\ConnectFour\Application\Game\Command\AbortCommand; @@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -final class ConnectFourController +final class GameController { public function __construct( private readonly Bus $connectFourCommandBus, diff --git a/src/WebInterface/Presentation/Http/Form/LoginType.php b/src/Identity/Port/Adapter/Http/Form/LoginType.php similarity index 95% rename from src/WebInterface/Presentation/Http/Form/LoginType.php rename to src/Identity/Port/Adapter/Http/Form/LoginType.php index d72336073..a06cc1d57 100644 --- a/src/WebInterface/Presentation/Http/Form/LoginType.php +++ b/src/Identity/Port/Adapter/Http/Form/LoginType.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Gaming\WebInterface\Presentation\Http\Form; +namespace Gaming\Identity\Port\Adapter\Http\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\EmailType; diff --git a/src/WebInterface/Presentation/Http/Form/SignupType.php b/src/Identity/Port/Adapter/Http/Form/SignupType.php similarity index 97% rename from src/WebInterface/Presentation/Http/Form/SignupType.php rename to src/Identity/Port/Adapter/Http/Form/SignupType.php index b17bd86a8..c514676d6 100644 --- a/src/WebInterface/Presentation/Http/Form/SignupType.php +++ b/src/Identity/Port/Adapter/Http/Form/SignupType.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Gaming\WebInterface\Presentation\Http\Form; +namespace Gaming\Identity\Port\Adapter\Http\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\EmailType; diff --git a/src/WebInterface/Presentation/Http/LoginController.php b/src/Identity/Port/Adapter/Http/LoginController.php similarity index 81% rename from src/WebInterface/Presentation/Http/LoginController.php rename to src/Identity/Port/Adapter/Http/LoginController.php index 2e49ccdce..ae6154862 100644 --- a/src/WebInterface/Presentation/Http/LoginController.php +++ b/src/Identity/Port/Adapter/Http/LoginController.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Gaming\WebInterface\Presentation\Http; +namespace Gaming\Identity\Port\Adapter\Http; use Gaming\Common\Bus\Bus; use Gaming\Common\Domain\Exception\DomainException; use Gaming\Common\Domain\Integration\FormViolationMapper; use Gaming\Identity\Application\User\Query\UserByEmailQuery; +use Gaming\Identity\Port\Adapter\Http\Form\LoginType; use Gaming\WebInterface\Infrastructure\Security\User; -use Gaming\WebInterface\Presentation\Http\Form\LoginType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -44,12 +44,16 @@ public function indexAction(#[CurrentUser] ?User $user, Request $request): Respo $email = (string)$form->get('email')->getData(); $user = $this->identityQueryBus->handle(new UserByEmailQuery($email)); - return $this->redirectToRoute('login_check_inbox', [ + return $this->redirectToRoute('identity_login_check_inbox', [ 'loginUrl' => $user === null ? null : $this->loginLinkHandler->createLoginLink( new User($user->userId) ), 'signupUrl' => $user !== null ? null : $this->uriSigner->sign( - $this->generateUrl('signup_confirm', ['email' => $email], UrlGeneratorInterface::ABSOLUTE_URL) + $this->generateUrl( + 'identity_signup_confirm', + ['email' => $email], + UrlGeneratorInterface::ABSOLUTE_URL + ) ) ]); } catch (DomainException $e) { @@ -57,7 +61,7 @@ public function indexAction(#[CurrentUser] ?User $user, Request $request): Respo } } - return $this->render('@web-interface/login/index.html.twig', [ + return $this->render('@identity/login/index.html.twig', [ 'form' => $form, 'lastAuthenticationError' => $this->authenticationUtils->getLastAuthenticationError() ]); @@ -69,6 +73,6 @@ public function checkInboxAction(#[CurrentUser] ?User $user): Response return $this->redirectToRoute('lobby'); } - return $this->render('@web-interface/login/check-inbox.html.twig'); + return $this->render('@identity/login/check-inbox.html.twig'); } } diff --git a/src/WebInterface/Presentation/Http/SignupController.php b/src/Identity/Port/Adapter/Http/SignupController.php similarity index 84% rename from src/WebInterface/Presentation/Http/SignupController.php rename to src/Identity/Port/Adapter/Http/SignupController.php index 53ec4cc72..3269db2d7 100644 --- a/src/WebInterface/Presentation/Http/SignupController.php +++ b/src/Identity/Port/Adapter/Http/SignupController.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Gaming\WebInterface\Presentation\Http; +namespace Gaming\Identity\Port\Adapter\Http; use Gaming\Common\Bus\Bus; use Gaming\Common\Domain\Exception\DomainException; use Gaming\Common\Domain\Integration\FormViolationMapper; use Gaming\Identity\Application\User\Command\SignUpCommand; +use Gaming\Identity\Port\Adapter\Http\Form\SignupType; use Gaming\WebInterface\Infrastructure\Security\Security; use Gaming\WebInterface\Infrastructure\Security\User; -use Gaming\WebInterface\Presentation\Http\Form\SignupType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -48,10 +48,14 @@ public function indexAction(#[CurrentUser] ?User $user, Request $request): Respo ) ); - return $this->redirectToRoute('signup_verify_email', [ + return $this->redirectToRoute('identity_signup_verify_email', [ 'username' => $form->get('username')->getData(), 'confirmUrl' => $this->uriSigner->sign( - $this->generateUrl('signup_confirm', $form->getData(), UrlGeneratorInterface::ABSOLUTE_URL) + $this->generateUrl( + 'identity_signup_confirm', + $form->getData(), + UrlGeneratorInterface::ABSOLUTE_URL + ) ) ]); } catch (DomainException $e) { @@ -59,7 +63,7 @@ public function indexAction(#[CurrentUser] ?User $user, Request $request): Respo } } - return $this->render('@web-interface/signup/index.html.twig', ['form' => $form]); + return $this->render('@identity/signup/index.html.twig', ['form' => $form]); } public function verifyEmailAction(#[CurrentUser] ?User $user, Request $request): Response @@ -68,7 +72,7 @@ public function verifyEmailAction(#[CurrentUser] ?User $user, Request $request): return $this->redirectToRoute('lobby'); } - return $this->render('@web-interface/signup/verify-email.html.twig'); + return $this->render('@identity/signup/verify-email.html.twig'); } public function confirmAction(#[CurrentUser] ?User $user, Request $request): Response @@ -109,6 +113,6 @@ public function confirmAction(#[CurrentUser] ?User $user, Request $request): Res } } - return $this->render('@web-interface/signup/confirm.html.twig', ['form' => $form]); + return $this->render('@identity/signup/confirm.html.twig', ['form' => $form]); } } diff --git a/src/WebInterface/Presentation/Http/View/login/check-inbox.html.twig b/src/Identity/Port/Adapter/Http/View/login/check-inbox.html.twig similarity index 91% rename from src/WebInterface/Presentation/Http/View/login/check-inbox.html.twig rename to src/Identity/Port/Adapter/Http/View/login/check-inbox.html.twig index 8e282e246..e84f7cb32 100644 --- a/src/WebInterface/Presentation/Http/View/login/check-inbox.html.twig +++ b/src/Identity/Port/Adapter/Http/View/login/check-inbox.html.twig @@ -1,4 +1,4 @@ -{% extends '@web-interface/login/layout/base.html.twig' %} +{% extends '@identity/login/layout/base.html.twig' %} {% set page_title = 'Check your inbox!' %} @@ -16,7 +16,7 @@
We’ve sent a login link to your inbox. Click the link in the email to log in. If you don't see the email, check your spam folder or - click here to try again. + click here to try again.
{% if app.request.get('loginUrl') %}diff --git a/src/WebInterface/Presentation/Http/View/login/index.html.twig b/src/Identity/Port/Adapter/Http/View/login/index.html.twig similarity index 73% rename from src/WebInterface/Presentation/Http/View/login/index.html.twig rename to src/Identity/Port/Adapter/Http/View/login/index.html.twig index 5ccdb1f82..a4ea3b48d 100644 --- a/src/WebInterface/Presentation/Http/View/login/index.html.twig +++ b/src/Identity/Port/Adapter/Http/View/login/index.html.twig @@ -1,4 +1,4 @@ -{% extends '@web-interface/login/layout/base.html.twig' %} +{% extends '@identity/login/layout/base.html.twig' %} {% set page_title = 'Login to your account' %} diff --git a/src/WebInterface/Presentation/Http/View/login/layout/base.html.twig b/src/Identity/Port/Adapter/Http/View/login/layout/base.html.twig similarity index 75% rename from src/WebInterface/Presentation/Http/View/login/layout/base.html.twig rename to src/Identity/Port/Adapter/Http/View/login/layout/base.html.twig index 2c4dcb3ec..cdd7f0a89 100644 --- a/src/WebInterface/Presentation/Http/View/login/layout/base.html.twig +++ b/src/Identity/Port/Adapter/Http/View/login/layout/base.html.twig @@ -7,6 +7,6 @@
{% endblock %} diff --git a/src/WebInterface/Presentation/Http/View/signup/confirm.html.twig b/src/Identity/Port/Adapter/Http/View/signup/confirm.html.twig similarity index 74% rename from src/WebInterface/Presentation/Http/View/signup/confirm.html.twig rename to src/Identity/Port/Adapter/Http/View/signup/confirm.html.twig index 806206ef7..8fdcc5f0e 100644 --- a/src/WebInterface/Presentation/Http/View/signup/confirm.html.twig +++ b/src/Identity/Port/Adapter/Http/View/signup/confirm.html.twig @@ -1,4 +1,4 @@ -{% extends '@web-interface/signup/layout/base.html.twig' %} +{% extends '@identity/signup/layout/base.html.twig' %} {% set page_title = 'Confirm and play!' %} {% set step = 3 %} diff --git a/src/WebInterface/Presentation/Http/View/signup/index.html.twig b/src/Identity/Port/Adapter/Http/View/signup/index.html.twig similarity index 74% rename from src/WebInterface/Presentation/Http/View/signup/index.html.twig rename to src/Identity/Port/Adapter/Http/View/signup/index.html.twig index 5a143a437..b644d2d81 100644 --- a/src/WebInterface/Presentation/Http/View/signup/index.html.twig +++ b/src/Identity/Port/Adapter/Http/View/signup/index.html.twig @@ -1,4 +1,4 @@ -{% extends '@web-interface/signup/layout/base.html.twig' %} +{% extends '@identity/signup/layout/base.html.twig' %} {% set page_title = 'Sign up to play!' %} {% set step = 1 %} diff --git a/src/WebInterface/Presentation/Http/View/signup/layout/base.html.twig b/src/Identity/Port/Adapter/Http/View/signup/layout/base.html.twig similarity index 86% rename from src/WebInterface/Presentation/Http/View/signup/layout/base.html.twig rename to src/Identity/Port/Adapter/Http/View/signup/layout/base.html.twig index a182e2812..0ef797a2a 100644 --- a/src/WebInterface/Presentation/Http/View/signup/layout/base.html.twig +++ b/src/Identity/Port/Adapter/Http/View/signup/layout/base.html.twig @@ -12,6 +12,6 @@ {% endblock %} diff --git a/src/WebInterface/Presentation/Http/View/signup/verify-email.html.twig b/src/Identity/Port/Adapter/Http/View/signup/verify-email.html.twig similarity index 86% rename from src/WebInterface/Presentation/Http/View/signup/verify-email.html.twig rename to src/Identity/Port/Adapter/Http/View/signup/verify-email.html.twig index 55caa53b1..e5d776d30 100644 --- a/src/WebInterface/Presentation/Http/View/signup/verify-email.html.twig +++ b/src/Identity/Port/Adapter/Http/View/signup/verify-email.html.twig @@ -1,4 +1,4 @@ -{% extends '@web-interface/signup/layout/base.html.twig' %} +{% extends '@identity/signup/layout/base.html.twig' %} {% set page_title = 'Confirm and play!' %} {% set step = 2 %} @@ -17,7 +17,7 @@We've sent a verification link to your inbox. Click the link in the email to complete your signup. If you don't see the email, check your spam folder or - click here to try again. + click here to try again.
No email has been sent because this feature is still in development, diff --git a/templates/layout/condensed.html.twig b/templates/layout/condensed.html.twig index abc24ae64..289e54f37 100644 --- a/templates/layout/condensed.html.twig +++ b/templates/layout/condensed.html.twig @@ -49,8 +49,8 @@
{% endif %}