Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ee5b51a

Browse filesBrowse files
committed
bug #39878 [doctrine-bridge] Add username to UserNameNotFoundException
1 parent 6af4446 commit ee5b51a
Copy full SHA for ee5b51a

File tree

4 files changed

+28
-7
lines changed
Filter options

4 files changed

+28
-7
lines changed

‎src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ public function loadUserByUsername($username)
6262
}
6363

6464
if (null === $user) {
65-
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
65+
$e = new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
66+
$e->setUsername($username);
67+
68+
throw $e;
6669
}
6770

6871
return $user;
@@ -92,7 +95,10 @@ public function refreshUser(UserInterface $user)
9295

9396
$refreshedUser = $repository->find($id);
9497
if (null === $refreshedUser) {
95-
throw new UsernameNotFoundException('User with id '.json_encode($id).' not found.');
98+
$e = new UsernameNotFoundException('User with id '.json_encode($id).' not found.');
99+
$e->setUsername(json_encode($id));
100+
101+
throw $e;
96102
}
97103
}
98104

‎src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/SecuredPageBundle/Security/Core/User/ArrayUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/SecuredPageBundle/Security/Core/User/ArrayUserProvider.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ public function loadUserByUsername($username)
3434
$user = $this->getUser($username);
3535

3636
if (null === $user) {
37-
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
37+
$e = new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
38+
$e->setUsername($username);
39+
40+
throw $e;
3841
}
3942

4043
return $user;

‎src/Symfony/Component/Ldap/Security/LdapUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Security/LdapUserProvider.php
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,27 @@ public function loadUserByUsername($username)
7373
$query = str_replace('{username}', $username, $this->defaultSearch);
7474
$search = $this->ldap->query($this->baseDn, $query);
7575
} catch (ConnectionException $e) {
76-
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username), 0, $e);
76+
$e = new UsernameNotFoundException(sprintf('User "%s" not found.', $username), 0, $e);
77+
$e->setUsername($username);
78+
79+
throw $e;
7780
}
7881

7982
$entries = $search->execute();
8083
$count = \count($entries);
8184

8285
if (!$count) {
83-
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
86+
$e = new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
87+
$e->setUsername($username);
88+
89+
throw $e;
8490
}
8591

8692
if ($count > 1) {
87-
throw new UsernameNotFoundException('More than one user found.');
93+
$e = new UsernameNotFoundException('More than one user found.');
94+
$e->setUsername($username);
95+
96+
throw $e;
8897
}
8998

9099
$entry = $entries[0];

‎src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ private function authenticateViaGuard(AuthenticatorInterface $guardAuthenticator
105105
$user = $guardAuthenticator->getUser($token->getCredentials(), $this->userProvider);
106106

107107
if (null === $user) {
108-
throw new UsernameNotFoundException(sprintf('Null returned from "%s::getUser()".', \get_class($guardAuthenticator)));
108+
$e = new UsernameNotFoundException(sprintf('Null returned from "%s::getUser()".', \get_class($guardAuthenticator)));
109+
$e->setUsername($token->getUsername());
110+
111+
throw $e;
109112
}
110113

111114
if (!$user instanceof UserInterface) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.