src/Controller/SecurityController.php line 36

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\PatientRepository;
  4. use App\Repository\UserPatientRepository;
  5. use App\Repository\UtilisateurRepository;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  10. class SecurityController extends AbstractController
  11. {
  12.     #[Route(path'/login'name'app_login')]
  13.     public function login(AuthenticationUtils $authenticationUtils): Response
  14.     {
  15.         if ($this->getUser()) {
  16.             return $this->redirectToRoute('home');
  17.         }
  18.         // get the login error if there is one
  19.         $error $authenticationUtils->getLastAuthenticationError();
  20.         // last username entered by the user
  21.         $lastUsername $authenticationUtils->getLastUsername();
  22.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  23.     }
  24.     #[Route(path'/logout'name'app_logout')]
  25.     public function logout(): void
  26.     {
  27.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  28.     }
  29.     #[Route(path'/admin'name'home')]
  30.     public function index(UserPatientRepository $userPatientRepositoryUtilisateurRepository $utilisateurRepository): response
  31.     {
  32.         return $this->render('security/home.html.twig', [
  33.             'patients' => $userPatientRepository->findAll(),
  34.             'personnels' => $utilisateurRepository->findAll(),
  35.             'controller_name' => 'HomeController',
  36.         ]);
  37.     }
  38.     #[Route(path'/'name'home_slash')]
  39.     public function home(): response
  40.     {
  41.         return $this->redirectToRoute('home');
  42.     }
  43. }