Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ee9f985

Browse files
committed
bug #39878 [doctrine-bridge] Add username to UserNameNotFoundException
1 parent 6af4446 commit ee9f985

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

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

Lines 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+
$ex = new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
66+
$ex->setUsername($username);
67+
68+
throw $ex;
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+
$ex = new UsernameNotFoundException('User with id '.json_encode($id).' not found.');
99+
$ex->setUsername(json_encode($id));
100+
101+
throw $ex;
96102
}
97103
}
98104

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

Lines 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+
$ex = new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
38+
$ex->setUsername($username);
39+
40+
throw $ex;
3841
}
3942

4043
return $user;

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,20 @@ 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+
$ex = new UsernameNotFoundException(sprintf('User "%s" not found.', $username), 0, $e);
77+
$ex->setUsername($username);
78+
79+
throw $ex;
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+
$ex = new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
87+
$ex->setUsername($username);
88+
89+
throw $ex;
8490
}
8591

8692
if ($count > 1) {

0 commit comments

Comments
 (0)