bug symfony/symfony#39878 [doctrine-bridge] Add username to UserNameNotFoundException
This commit is contained in:
parent
6af444607c
commit
ee5b51af78
@ -62,7 +62,10 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null === $user) {
|
if (null === $user) {
|
||||||
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
|
$e = new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
|
||||||
|
$e->setUsername($username);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
@ -92,7 +95,10 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter
|
|||||||
|
|
||||||
$refreshedUser = $repository->find($id);
|
$refreshedUser = $repository->find($id);
|
||||||
if (null === $refreshedUser) {
|
if (null === $refreshedUser) {
|
||||||
throw new UsernameNotFoundException('User with id '.json_encode($id).' not found.');
|
$e = new UsernameNotFoundException('User with id '.json_encode($id).' not found.');
|
||||||
|
$e->setUsername(json_encode($id));
|
||||||
|
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,10 @@ class ArrayUserProvider implements UserProviderInterface
|
|||||||
$user = $this->getUser($username);
|
$user = $this->getUser($username);
|
||||||
|
|
||||||
if (null === $user) {
|
if (null === $user) {
|
||||||
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
|
$e = new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
|
||||||
|
$e->setUsername($username);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
@ -73,18 +73,27 @@ class LdapUserProvider implements UserProviderInterface, PasswordUpgraderInterfa
|
|||||||
$query = str_replace('{username}', $username, $this->defaultSearch);
|
$query = str_replace('{username}', $username, $this->defaultSearch);
|
||||||
$search = $this->ldap->query($this->baseDn, $query);
|
$search = $this->ldap->query($this->baseDn, $query);
|
||||||
} catch (ConnectionException $e) {
|
} catch (ConnectionException $e) {
|
||||||
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username), 0, $e);
|
$e = new UsernameNotFoundException(sprintf('User "%s" not found.', $username), 0, $e);
|
||||||
|
$e->setUsername($username);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
$entries = $search->execute();
|
$entries = $search->execute();
|
||||||
$count = \count($entries);
|
$count = \count($entries);
|
||||||
|
|
||||||
if (!$count) {
|
if (!$count) {
|
||||||
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
|
$e = new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
|
||||||
|
$e->setUsername($username);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($count > 1) {
|
if ($count > 1) {
|
||||||
throw new UsernameNotFoundException('More than one user found.');
|
$e = new UsernameNotFoundException('More than one user found.');
|
||||||
|
$e->setUsername($username);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = $entries[0];
|
$entry = $entries[0];
|
||||||
|
@ -105,7 +105,10 @@ class GuardAuthenticationProvider implements AuthenticationProviderInterface
|
|||||||
$user = $guardAuthenticator->getUser($token->getCredentials(), $this->userProvider);
|
$user = $guardAuthenticator->getUser($token->getCredentials(), $this->userProvider);
|
||||||
|
|
||||||
if (null === $user) {
|
if (null === $user) {
|
||||||
throw new UsernameNotFoundException(sprintf('Null returned from "%s::getUser()".', \get_class($guardAuthenticator)));
|
$e = new UsernameNotFoundException(sprintf('Null returned from "%s::getUser()".', \get_class($guardAuthenticator)));
|
||||||
|
$e->setUsername($token->getUsername());
|
||||||
|
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user instanceof UserInterface) {
|
if (!$user instanceof UserInterface) {
|
||||||
|
Reference in New Issue
Block a user