0 follower

Final Class Yiisoft\Auth\Handler\AuthenticationFailureHandler

InheritanceYiisoft\Auth\Handler\AuthenticationFailureHandler
ImplementsPsr\Http\Server\RequestHandlerInterface

Default authentication failure handler. Responds with "401 Unauthorized" HTTP status code.

Method Details

Hide inherited methods

__construct() public method

public __construct( \Psr\Http\Message\ResponseFactoryInterface $responseFactory ): mixed
$responseFactory \Psr\Http\Message\ResponseFactoryInterface

                public function __construct(
    private readonly ResponseFactoryInterface $responseFactory,
) {}

            
handle() public method

public handle( \Psr\Http\Message\ServerRequestInterface $request ): \Psr\Http\Message\ResponseInterface
$request \Psr\Http\Message\ServerRequestInterface

                public function handle(ServerRequestInterface $request): ResponseInterface
{
    $response = $this->responseFactory->createResponse(Status::UNAUTHORIZED);
    $response
        ->getBody()
        ->write('Your request was made with invalid credentials.');
    return $response;
}