/** * Returns the ID of the challenge 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. */ protected function getChallenger(Request $request) { foreach ($this->authCollector->getSortedProviders() as $provider_id => $provider) { if ($provider instanceof AuthenticationProviderChallengeInterface && !$provider->applies($request) && $this->applyFilter($request, FALSE, $provider_id)) { return $provider_id; } } }
/** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = NULL) { $this->data['name'] = $this->currentUser->getDisplayName(); $this->data['authenticated'] = $this->currentUser->isAuthenticated(); $this->data['roles'] = []; $storage = $this->entityManager->getStorage('user_role'); foreach ($this->currentUser->getRoles() as $role) { $entity = $storage->load($role); $this->data['roles'][] = $entity->label(); } foreach ($this->providerCollector->getSortedProviders() as $provider_id => $provider) { if ($provider->applies($request)) { $this->data['provider'] = $provider_id; } } $this->data['anonymous'] = $this->configFactory->get('user.settings')->get('anonymous'); }