src/Controller/SecurityController.php line 42

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Date;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\HttpFoundation\Session\Session;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  11. use Symfony\Component\Security\Http\LoginLink\LoginLinkHandlerInterface;
  12. class SecurityController extends AbstractController
  13. {
  14.     private $entityManager;
  15.     public function __construct(EntityManagerInterface $entityManager)
  16.     {
  17.         $this->entityManager $entityManager;
  18.     }
  19.     /**
  20.      * @Route("/attente/hgdfsgui4568fdg84f8gdfd98g", name="app_attente")
  21.      */
  22.     public function attente(AuthenticationUtils $authenticationUtils): Response
  23.     {
  24.         return $this->render('first/index.html.twig', [
  25.             'last_username' => "",
  26.             'error' => "",
  27.             'demande_confirmation' => "",
  28.             'confirmation_compte' => "",
  29.             'listeDate' => ""
  30.         ]);
  31.     }
  32.     /**
  33.      * @Route("/", name="app_login")
  34.      */
  35.     public function login(AuthenticationUtils $authenticationUtils): Response
  36.     {
  37.         if ($this->getUser()) {
  38.             if ($this->getUser()->getRoles()[0] == "ROLE_ADMIN"){
  39.                 return $this->redirectToRoute('app_admin_accueil');
  40.             }elseif($this->getUser()->getRoles()[0] == "ROLE_BENEFICIAIRE"){
  41.                 return $this->redirectToRoute('app_beneficiaire_accueil');
  42.             }elseif($this->getUser()->getRoles()[0] == "ROLE_CINEMA"){
  43.                 return $this->redirectToRoute('app_cinema_accueil');
  44.             }else{
  45.                 return $this->redirectToRoute('app_logout');
  46.             }
  47.         }
  48.         // get the login error if there is one
  49.         $error $authenticationUtils->getLastAuthenticationError();
  50.         // last username entered by the user
  51.         $lastUsername $authenticationUtils->getLastUsername();
  52.         return $this->render('security/login.html.twig', [
  53.             'last_username' => $lastUsername,
  54.             'error' => $error,
  55.             'demande_confirmation' => "",
  56.             'confirmation_compte' => "",
  57.             ]);
  58.     }
  59.     /**
  60.      * @Route("/deconnexion", name="app_logout")
  61.      */
  62.     public function logout(Request $request)
  63.     {
  64.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  65.     }
  66. }