src/Controller/SecurityController.php line 99

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Security\Core\Security;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Contracts\Translation\TranslatorInterface;
  10. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  11. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  12. use App\Entity\User;
  13. class SecurityController extends AbstractController
  14. {
  15.     private $translator;
  16.     public function __construct(TranslatorInterface $translator)
  17.     {
  18.         $this->translator $translator;
  19.     }
  20.     /**
  21.      * @Route("/login", name="app_login")
  22.      */
  23.     public function login(AuthenticationUtils $authenticationUtils): Response
  24.     {
  25.         // get the login error if there is one
  26.         $error $authenticationUtils->getLastAuthenticationError();
  27.         // last username entered by the user
  28.         $lastUsername $authenticationUtils->getLastUsername();
  29.         return $this->render('security/login_front.html.twig', [
  30.             'last_username' => $lastUsername,
  31.             'error'         => $error,
  32.         ]);
  33.     }
  34.     
  35. /**
  36.      * @Route("/login_check", name="login_check")
  37.      */
  38.     public function loginCheck(AuthenticationUtils $authenticationUtils): Response
  39.     {
  40.         // get the login error if there is one
  41.         $error $authenticationUtils->getLastAuthenticationError();
  42.         // last username entered by the user
  43.         $lastUsername $authenticationUtils->getLastUsername();
  44.         return $this->render('security/login_front.html.twig', [
  45.             'last_username' => $lastUsername,
  46.             'error'         => $error,
  47.         ]);
  48.     }
  49.     /**
  50.      * @Route("/login_fail", name="login_fail")
  51.      */
  52.     public function loginFail(Request $request)
  53.     {
  54.         $session $request->getSession();
  55.         $title=""
  56.         $message $this->translator->trans('compte.register.inscription.erreur.login_password', array(), 'app');
  57.         $session->getFlashBag()->add('danger', ['type' => 'danger''title' => $title'message' => $message]);
  58.         return $this->redirectToRoute('compte');
  59.     }
  60.     /**
  61.      * @Route("/accessDenied", name="login_accessdenied")
  62.      */
  63.     public function accessDenied(Request $request)
  64.     {
  65.         $session $request->getSession();
  66.         $title=""
  67.         $message $this->translator->trans('compte.register.inscription.erreur.acces_refuse', array(), 'app');
  68.         $session->getFlashBag()->add('danger', ['type' => 'danger''title' => $title'message' => $message]);
  69.         
  70.         return $this->redirectToRoute('compte');
  71.     }
  72.     /**
  73.      * @Route("/admin/login", name="login_bo")
  74.      */
  75.     public function loginBo(AuthenticationUtils $authenticationUtils)
  76.     {
  77.         // get the login error if there is one
  78.         $error $authenticationUtils->getLastAuthenticationError();
  79.         // last username entered by the user
  80.         $lastUsername $authenticationUtils->getLastUsername();
  81.         return $this->render('security/login_back.html.twig', [
  82.             'last_username' => $lastUsername,
  83.             'error'         => $error,
  84.         ]);
  85.     }
  86.   
  87. }