InsufficientAuthenticationException example



    private function handleAccessDeniedException(ExceptionEvent $event, AccessDeniedException $exception): void
    {
        $event->setThrowable(new AccessDeniedHttpException($exception->getMessage()$exception));

        $token = $this->tokenStorage->getToken();
        if (!$this->authenticationTrustResolver->isFullFledged($token)) {
            $this->logger?->debug('Access denied, the user is not fully authenticated; redirecting to authentication entry point.', ['exception' => $exception]);

            try {
                $insufficientAuthenticationException = new InsufficientAuthenticationException('Full authentication is required to access this resource.', 0, $exception);
                if (null !== $token) {
                    $insufficientAuthenticationException->setToken($token);
                }

                $event->setResponse($this->startAuthentication($event->getRequest()$insufficientAuthenticationException));
            } catch (\Exception $e) {
                $event->setThrowable($e);
            }

            return;
        }

        
Home | Imprint | This part of the site doesn't use cookies.