What i need
Username : ABC@gmail.com email address stored in db & input will be lowercase.
there is no canonical field which has lower case email address stored.
The solution
select * from view where trim(lower(username))=trim(lower(input_username))
I read Url https://symfony.com/doc/current/security/user_provider.html
security.yml
providers:
entity_provider:
entity:
class: App\Entity\User
property: username
I have commented out property as i need to call loadUserByUsername in repository.
Service.yml
app.repository.user_repositry:
class: Doctrine\ORM\EntityRepository
autowire: false
autoconfigure: true
factory: ["@doctrine.orm.entity_manager", getRepository]
arguments: []
tags: ['doctrine.repository_service']
Repository code
class UserRepository extends EntityRepository implements UserLoaderInterface
{
public function loadUserByUsername($username)
{
return $em->createQuery(
'SELECT u
FROM App\CORE\Entity\User u
WHERE LOWER(u.username) = :query'
)
//->where('LOWER(user.username) = :username')
->setParameter('query', strtolower($username))
//->setParameter('query', $usernameOrEmail)
->getQuery()
->getOneOrNullResult();
}
}
Problem occurs
You must either make the "App\Entity\User" entity Doctrine Repository ("Doctrine\ORM\EntityRepository") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration."
If i set Entity Abstract class then My app stops working
namespace App\CORE\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
use Doctrine\ORM\Mapping\MappedSuperclass;
/**
* @ORM\Table(name="users")
* @ORM\Entity
*/
class User implements UserInterface,\Serializable
After fixing eror making enity abstract causing issues.
//abstract class User extends EntityRepository implements UserLoaderInterface,UserInterface,\Serializable
if i change enity to abstract my application not working.
- any suggestion can i implement without making entity class abstract.
Refrence