src/Controller/SecurityController.php line 47

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