From d6ac63339e140f2aca1acb97b35e8318cefffda6 Mon Sep 17 00:00:00 2001 From: Romain Lebbadi-Breteau <romain@lebbadi.fr> Date: Sun, 5 Feb 2023 08:26:25 -0500 Subject: [PATCH] better grepping --- assets/react/controllers/Menu.tsx | 2 +- src/Controller/EconomicController.php | 3 ++- src/Controller/HomeController.php | 7 +++++++ src/Controller/SummaryController.php | 2 ++ src/Controller/TransactionController.php | 2 ++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/assets/react/controllers/Menu.tsx b/assets/react/controllers/Menu.tsx index c7d1cd3..3eade34 100644 --- a/assets/react/controllers/Menu.tsx +++ b/assets/react/controllers/Menu.tsx @@ -26,7 +26,7 @@ export default function Menu() { </a> </li> <li> - <a href="/"> + <a href="/logout"> <span className="item">Déconnexion</span> </a> </li> diff --git a/src/Controller/EconomicController.php b/src/Controller/EconomicController.php index fe444b0..5edfc53 100644 --- a/src/Controller/EconomicController.php +++ b/src/Controller/EconomicController.php @@ -6,8 +6,9 @@ use App\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -use Symfony\Bundle\SecurityBundle\Security; +use Symfony\Component\Security\Http\Attribute\IsGranted; +#[IsGranted('ROLE_USER')] class EconomicController extends AbstractController { #[Route('/economic', name: 'app_economic')] diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index d4931df..5f718d3 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -60,5 +60,12 @@ class HomeController extends AbstractController { return $this->redirectToRoute('login'); } + + #[Route("/logout", name: "app_logout")] + public function logout() + { + // controller can be blank: it will never be called! + throw new \Exception('Don\'t forget to activate logout in security.yaml'); + } } diff --git a/src/Controller/SummaryController.php b/src/Controller/SummaryController.php index 122e66e..ffbf5fa 100644 --- a/src/Controller/SummaryController.php +++ b/src/Controller/SummaryController.php @@ -6,9 +6,11 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use App\Service\SummaryService; +use Symfony\Component\Security\Http\Attribute\IsGranted; use Symfony\UX\Chartjs\Model\Chart; use Symfony\UX\Chartjs\Builder\ChartBuilderInterface; +#[IsGranted('ROLE_USER')] class SummaryController extends AbstractController { #[Route('/summary', name: 'app_summary')] diff --git a/src/Controller/TransactionController.php b/src/Controller/TransactionController.php index a0e3e4c..893db07 100644 --- a/src/Controller/TransactionController.php +++ b/src/Controller/TransactionController.php @@ -5,7 +5,9 @@ namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Security\Http\Attribute\IsGranted; +#[IsGranted('ROLE_USER')] class TransactionController extends AbstractController { #[Route('/transaction', name: 'app_transaction')] -- GitLab