src/EventListener/AuthenticationFailureListener.php line 18

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: rostandnj
  5.  * Date: 19/3/19
  6.  * Time: 11:19 AM
  7.  */
  8. namespace App\EventListener;
  9. use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationFailureEvent;
  10. use Lexik\Bundle\JWTAuthenticationBundle\Response\JWTAuthenticationFailureResponse;
  11. class AuthenticationFailureListener
  12. {
  13.     /**
  14.      * @param AuthenticationFailureEvent $event
  15.      */
  16.     public function onAuthenticationFailureResponse(AuthenticationFailureEvent $event)
  17.     {
  18.         $data = [
  19.             'status'  => '401 Unauthorized',
  20.             'message' => 'Bad credentials, please verify that your username/password are correctly set',
  21.             'code'=>'bad_login'
  22.         ];
  23.         $response = new JWTAuthenticationFailureResponse($data);
  24.         $event->setResponse($response);
  25.     }
  26. }