| Current Path : /var/www/v3.cesa.co.za/src/UserBundle/Security/ |
| Current File : /var/www/v3.cesa.co.za/src/UserBundle/Security/LoginFailureHandler.php |
<?php
namespace App\UserBundle\Security;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Authentication\Token\Storage\UsageTrackingTokenStorage;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Router;
class LoginFailureHandler implements AuthenticationFailureHandlerInterface
{
/**
* Service Container
* @var object
*/
private $container = null;
protected $router;
protected $security;
public function __construct(ContainerInterface $container, Router $router, UsageTrackingTokenStorage $security)
{
$this->router = $router;
$this->security = $security;
$this->setContainer($container);
}
/**
* Get Container
*
* @return ContainerInterface $container
*/
public function getContainer()
{
return $this->container;
}
/**
* Set Container
*
* @param ContainerInterface $container
* @return void
*/
public function setContainer($container)
{
$this->container = $container;
}
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response
{
// echo $exception->getMessage() . ' ' . $exception->getTraceAsString();
// exit;
$request->getSession()->getFlashBag()->add('error', 'Login failed. Please try again, register, or use our forgot password facility.');
return new RedirectResponse($this->router->generate('login'));
}
}