src/Controller/SecurityController.php line 56

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Form\LoginType;
  4. use Gregwar\CaptchaBundle\Type\CaptchaType;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\HttpFoundation\RedirectResponse;
  11. use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
  12. use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
  13. use Symfony\Component\EventDispatcher\EventDispatcher;
  14. use Symfony\Contracts\EventDispatcher\Event;
  15. use Symfony\Component\BrowserKit\Cookie;
  16. //use App\Security\LoginFormAuthenticator;
  17. use App\Security\LoginFormAuthenticator;
  18. use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
  19. use App\Entity\Usuario;
  20. use Symfony\Component\Security\Http\Util\TargetPathTrait;
  21. use Symfony\Component\HttpFoundation\Session\Session;
  22. class SecurityController extends AbstractController
  23. {
  24.     use TargetPathTrait;
  25.     /**
  26.      * @Route("/security", name="security")
  27.      */
  28.     public function index()
  29.     {
  30.         return $this->render('security/index.html.twig', [
  31.             'controller_name' => 'SecurityController',
  32.         ]);
  33.     }
  34.     /**
  35.      * @Route("/login", name="login")
  36.      */
  37.     public function login(AuthenticationUtils $authenticationUtilsRequest $request)
  38.     {
  39.         $defaultData = array('_username' => $authenticationUtils->getLastUsername());
  40.         $form $this->createForm(LoginType::class, $defaultData);
  41.         $form->handleRequest($request);
  42.         $error $authenticationUtils->getLastAuthenticationError();
  43.         return $this->render('security/loginForm.html.twig', array(
  44.                 'form' => $form->createView(),
  45.                 'error'         => $error,
  46.             )
  47.         );
  48.     }
  49. }