src/Controller/Kernel/SecurityController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Kernel;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  7. use App\Service\Kernel\KernelService;
  8. /**
  9.  * @Route("/{_locale}")
  10.  */
  11. class SecurityController extends AbstractController
  12. {
  13.     /**
  14.      * @Route("/login", name="app_login")
  15.      */
  16.     public function login(AuthenticationUtils $authenticationUtilsKernelService $kernelService): Response
  17.     {
  18.          if ($this->getUser()) {
  19.              
  20.              return $this->redirectToRoute('app_home', ['_locale' => "".$this->getUser()->getLocale()]);
  21.          }
  22.          
  23.         // get the login error if there is one
  24.         $error $authenticationUtils->getLastAuthenticationError();
  25.         $error2 $this->container->get('session')->get('error');
  26.         $this->container->get('session')->remove('error');
  27.         // last username entered by the user
  28.         $lastUsername $authenticationUtils->getLastUsername();
  29.         $facebook =  $kernelService->getApplicationInfoValue("Kernel.LoginWithFacebook");
  30.         $office356 $kernelService->getApplicationInfoValue("Kernel.LoginWithOffice365");
  31.         
  32.         return $this->render('security/login.html.twig'
  33.                 ['last_username' => $lastUsername'error' => $error'error2' => $error2,
  34.                     'facebook' => $facebook'office365' => $office356]
  35.                 );
  36.     }
  37.     /**
  38.      * @Route("/logout", name="app_logout")
  39.      */
  40.     public function logout()
  41.     {
  42.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  43.     }
  44. }