vendor/lexik/jwt-authentication-bundle/Response/JWTAuthenticationFailureResponse.php line 14

Open in your IDE?
  1. <?php
  2. namespace Lexik\Bundle\JWTAuthenticationBundle\Response;
  3. use Symfony\Component\HttpFoundation\JsonResponse;
  4. /**
  5.  * JWTAuthenticationFailureResponse.
  6.  *
  7.  * Response sent on failed JWT authentication (can be replaced by a custom Response).
  8.  *
  9.  * @author Robin Chalas <robin.chalas@gmail.com>
  10.  */
  11. final class JWTAuthenticationFailureResponse extends JWTCompatAuthenticationFailureResponse
  12. {
  13.     private $message;
  14.     public function __construct(string $message 'Bad credentials'int $statusCode JsonResponse::HTTP_UNAUTHORIZED)
  15.     {
  16.         $this->message $message;
  17.         parent::__construct(null$statusCode, ['WWW-Authenticate' => 'Bearer']);
  18.     }
  19.     /**
  20.      * Sets the failure message.
  21.      *
  22.      * @param string $message
  23.      *
  24.      * @return JWTAuthenticationFailureResponse
  25.      */
  26.     public function setMessage($message)
  27.     {
  28.         $this->message $message;
  29.         $this->setData();
  30.         return $this;
  31.     }
  32.     /**
  33.      * Gets the failure message.
  34.      *
  35.      * @return string
  36.      */
  37.     public function getMessage()
  38.     {
  39.         return $this->message;
  40.     }
  41. }