<?php
declare(strict_types = 1);
namespace App\EventListener;
use Symfony\Component\HttpFoundation\Response;
use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationFailureEvent;
use App\Model\Utility\RESTUtility;
class JWTAuthenticationFailureListener {
private $rest;
public function __construct(RESTUtility $rest) {
$this->rest = $rest;
}
/**
* @param AuthenticationFailureEvent $event
*/
public function onAuthenticationFailureResponse(AuthenticationFailureEvent $event) {
$errors['email'] = 'Incorrect email/password combination.|The password specified did not match with the user records and therefore he/she is not authorized to access the system.';
$response = $this->rest->setResponse($errors, Response::HTTP_FORBIDDEN);
$event->setResponse($response);
}
}