<?php
namespace App\Controller;
use App\Form\LoginType;
use Gregwar\CaptchaBundle\Type\CaptchaType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Contracts\EventDispatcher\Event;
use Symfony\Component\BrowserKit\Cookie;
//use App\Security\LoginFormAuthenticator;
use App\Security\LoginFormAuthenticator;
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
use App\Entity\Usuario;
use Symfony\Component\Security\Http\Util\TargetPathTrait;
use Symfony\Component\HttpFoundation\Session\Session;
class SecurityController extends AbstractController
{
use TargetPathTrait;
/**
* @Route("/security", name="security")
*/
public function index()
{
return $this->render('security/index.html.twig', [
'controller_name' => 'SecurityController',
]);
}
/**
* @Route("/login", name="login")
*/
public function login(AuthenticationUtils $authenticationUtils, Request $request)
{
$defaultData = array('_username' => $authenticationUtils->getLastUsername());
$form = $this->createForm(LoginType::class, $defaultData);
$form->handleRequest($request);
$error = $authenticationUtils->getLastAuthenticationError();
return $this->render('security/loginForm.html.twig', array(
'form' => $form->createView(),
'error' => $error,
)
);
}
}