src/BackOffice/ConfigurationBundle/Controller/SecurityController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\BackOffice\ConfigurationBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  6. use Symfony\Component\Security\Core\SecurityContext;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. class SecurityController extends AbstractController
  9. {
  10.     /**
  11.      * @Route("/login", name="login")
  12.      * @Template("@BackOfficeConfiguration/Security/login.html.twig")
  13.      */
  14.     public function loginAction(AuthenticationUtils $authenticationUtils)
  15.     {
  16.         // Si le visiteur est déjà identifié, on le redirige vers l'accueil
  17.         if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
  18.             return $this->redirect($this->generateUrl('admin_home'));
  19.         }
  20.         // get the login error if there is one
  21.         $error $authenticationUtils->getLastAuthenticationError();
  22.         // last username entered by the user
  23.         $lastUsername $authenticationUtils->getLastUsername();
  24.         return array(
  25.             // last username entered by the user
  26.             'last_username' => $lastUsername,
  27.             'error'         => $error,
  28.         );
  29.     }
  30. }