From bb166f7779cc3871d836b3a377c9a1a4f858c765 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Thu, 25 Apr 2024 15:27:16 +0200 Subject: [PATCH 1/3] #1234: Added logout functionality --- config/packages/security.yaml | 2 ++ src/Controller/Admin/DashboardController.php | 2 +- src/Controller/DefaultController.php | 10 ++++++++++ templates/navbar/_menu.html.twig | 1 + translations/navbar+intl-icu.da.xlf | 4 ++++ translations/navbar+intl-icu.en.xlf | 4 ++++ 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 32428eb2..3f23a4d4 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -19,6 +19,8 @@ security: - ItkDev\OpenIdConnectBundle\Security\CliLoginTokenAuthenticator - App\Security\AzureAdLoginAuthenticator entry_point: App\Security\AzureAdLoginAuthenticator + logout: + path: app_logout # activate different ways to authenticate # https://symfony.com/doc/current/security.html#firewalls-authentication diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php index 1cade3aa..34234f91 100644 --- a/src/Controller/Admin/DashboardController.php +++ b/src/Controller/Admin/DashboardController.php @@ -86,7 +86,7 @@ public function configureActions(): Actions public function configureUserMenu(UserInterface $user): UserMenu { // See AbstractDashboardController configureUserMenu method, here with unnecessary features such as logout removed - return UserMenu::new() + return parent::configureUserMenu($user) ->displayUserName() ->setName($user->getName()) ; diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php index bd5eb221..8c517c5e 100644 --- a/src/Controller/DefaultController.php +++ b/src/Controller/DefaultController.php @@ -92,4 +92,14 @@ public function redirectToUserSettings(AdminUrlGenerator $urlGenerator): Respons return $this->redirect($url); } + + /** + * @Route("/logout", name="app_logout") + */ + public function logout(): Response + { + return $this->render('default/index.html.twig', [ + 'controller_name' => 'DefaultController', + ]); + } } diff --git a/templates/navbar/_menu.html.twig b/templates/navbar/_menu.html.twig index 1ef27de1..ecad28bd 100644 --- a/templates/navbar/_menu.html.twig +++ b/templates/navbar/_menu.html.twig @@ -29,6 +29,7 @@ diff --git a/translations/navbar+intl-icu.da.xlf b/translations/navbar+intl-icu.da.xlf index 8925bf74..02bc0692 100644 --- a/translations/navbar+intl-icu.da.xlf +++ b/translations/navbar+intl-icu.da.xlf @@ -25,6 +25,10 @@ Create new Opret ny + + Log out + Log ud + diff --git a/translations/navbar+intl-icu.en.xlf b/translations/navbar+intl-icu.en.xlf index 8c1cc4bc..5fc22506 100644 --- a/translations/navbar+intl-icu.en.xlf +++ b/translations/navbar+intl-icu.en.xlf @@ -25,6 +25,10 @@ User settings User settings + + Log out + Log out + From f64af35c4c50f04db4c75623876fc98ed21d0396 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Thu, 25 Apr 2024 15:28:41 +0200 Subject: [PATCH 2/3] #1234: Updated CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index edff6417..47a4f3a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ about writing changes to this log. ## [Unreleased] +- [PR-394](https://github.com/itk-dev/naevnssekretariatet/pull/394) + Added logout functionality. - [PR-391](https://github.com/itk-dev/naevnssekretariatet/pull/391) Updated composer packages - [PR-377](https://github.com/itk-dev/naevnssekretariatet/pull/377) From acd87607f3ddce91337d1c2f60ecd29233fc7d67 Mon Sep 17 00:00:00 2001 From: jekuaitk Date: Sat, 27 Apr 2024 21:40:47 +0200 Subject: [PATCH 3/3] #1234: Removed redundant code --- src/Controller/DefaultController.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php index 8c517c5e..25803749 100644 --- a/src/Controller/DefaultController.php +++ b/src/Controller/DefaultController.php @@ -96,10 +96,9 @@ public function redirectToUserSettings(AdminUrlGenerator $urlGenerator): Respons /** * @Route("/logout", name="app_logout") */ - public function logout(): Response + public function logout(): void { - return $this->render('default/index.html.twig', [ - 'controller_name' => 'DefaultController', - ]); + // This will never be called so can be blank, + // cf. https://symfony.com/doc/5.x/security.html#logging-out } }