challengeException example


  public function onExceptionSendChallenge(ExceptionEvent $event) {
    if (isset($this->challengeProvider) && $event->isMainRequest()) {
      $request = $event->getRequest();
      $exception = $event->getThrowable();
      if ($exception instanceof AccessDeniedHttpException && !$this->authenticationProvider->applies($request) && (!isset($this->filter) || $this->filter->appliesToRoutedRequest($request, FALSE))) {
        $challenge_exception = $this->challengeProvider->challengeException($request$exception);
        if ($challenge_exception) {
          $event->setThrowable($challenge_exception);
        }
      }
    }
  }

  /** * Detect disallowed authentication methods on access denied exceptions. * * @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event * The event. */
return $result;
  }

  /** * {@inheritdoc} */
  public function challengeException(Request $request, \Exception $previous) {
    $provider_id = $this->getChallenger($request);

    if ($provider_id) {
      $provider = $this->authCollector->getProvider($provider_id);
      return $provider->challengeException($request$previous);
    }
  }

  /** * Returns the id of the authentication provider for a request. * * @param \Symfony\Component\HttpFoundation\Request $request * The incoming request. * * @return string|null * The id of the first authentication provider which applies to the request. * If no application detects appropriate credentials, then NULL is returned. */
Home | Imprint | This part of the site doesn't use cookies.