Commit 9e57746a authored by wilhelmhb's avatar wilhelmhb
Browse files

allow to get user by email and not username

parent 773659e4
namespace ApiBundle\Entity;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\EntityRepository;
class CustomerRepository extends EntityRepository implements UserProviderInterface
public function loadUserByUsername($username)
return $this->createQueryBuilder('u')
->where(' = :email')
->setParameter('email', $username)
public function refreshUser(UserInterface $user)
$class = get_class($user);
if (!$this->supportsClass($class)) {
throw new UnsupportedUserException(
'Instances of "%s" are not supported.',
return $this->find($user->getId());
public function supportsClass($class)
return $this->getEntityName() === $class
|| is_subclass_of($class, $this->getEntityName());
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment