mini\Exceptions\AuthenticationRequiredException class

Documentation

Exception thrown when an operation requires authentication

Maps to HTTP 401 (Unauthorized). Distinct from AccessDeniedException (403) which means "authenticated but not permitted".

Applications can register an exception converter to redirect to a login page:

$dispatcher->registerExceptionConverter(function(AuthenticationRequiredException $e): ResponseInterface {
    $returnTo = urlencode(request()->getRequestTarget());
    return new Response('', ['Location' => "/login/?returnTo=$returnTo"], 303);
});

Inheritance

Extends: Exception

Implements: Throwable Stringable

Properties (4)

protected mixed $message
protected mixed $code
protected string $file
protected int $line

Methods (10)

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Source

src/Exceptions/AuthenticationRequiredException.php:19-25