我刚刚实现了类似于本教程http://symfony.com/doc/current/cookbook/security/entity_provider.html的登录功能,但是当我尝试登录时,我得到:
"There is no user provider for user "App\SomeBundle\Entity\User""
我的存储库实现了所需的接口、对存储库的用户实体引用,并且在 security.yml 中我定义了提供程序,例如自定义实体提供程序的示例。我迷失了为什么会有错误。
在 security.yml 我有:
security:
encoders:
\App\SomeBundle\Entity\User: sha512
Symfony\Component\Security\Core\User\User: plaintext
role_hierarchy:
...
providers:
main:
entity: { class: AppSomeBundle:User }
...
用户实体的标头:
/**
* App\SomeBundle\Entity\User
*
* @ORM\Table(
* name="user",
* uniqueConstraints={
* @ORM\UniqueConstraint(name="email_unique", columns={"user_email"})
* }
* )
* @ORM\Entity(repositoryClass="App\SomeBundle\EntityRepository\UserRepository")
*/
class User implements UserInterface, EquatableInterface, \Serializable
{
和存储库的标题:
class UserRepository extends EntityRepository implements UserProviderInterface
{
感谢帮助。