Skip to content

Commit 84249ad

Browse files
committed
[#6228] backport to the 2.3 branch
1 parent 55ae7d3 commit 84249ad

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

Diff for: cookbook/security/entity_provider.rst

+1-12
Original file line numberDiff line numberDiff line change
@@ -433,30 +433,19 @@ interface requires three methods: ``loadUserByUsername($username)``,
433433

434434
use Symfony\Component\Security\Core\User\UserInterface;
435435
use Symfony\Component\Security\Core\User\UserProviderInterface;
436-
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
437436
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
438437
use Doctrine\ORM\EntityRepository;
439438

440439
class UserRepository extends EntityRepository implements UserProviderInterface
441440
{
442441
public function loadUserByUsername($username)
443442
{
444-
$user = $this->createQueryBuilder('u')
443+
return $this->createQueryBuilder('u')
445444
->where('u.username = :username OR u.email = :email')
446445
->setParameter('username', $username)
447446
->setParameter('email', $username)
448447
->getQuery()
449448
->getOneOrNullResult();
450-
451-
if (null === $user) {
452-
$message = sprintf(
453-
'Unable to find an active admin AppBundle:User object identified by "%s".',
454-
$username
455-
);
456-
throw new UsernameNotFoundException($message);
457-
}
458-
459-
return $user;
460449
}
461450

462451
public function refreshUser(UserInterface $user)

0 commit comments

Comments
 (0)