我刚刚实现了类似于本教程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
{
感谢您的帮助。
答案 0 :(得分:0)
尝试从编码器中删除前导\,并在provider语句中使用相同的类名。
这来自我自己的安全配置:
security:
encoders:
App\SomeBundle\Entity\User:
algorithm: sha512
iterations: 1024
encode_as_base64: true
providers:
user_db:
entity: { class: App\SomeBundle\Entity\User, property: username }
role_hierarchy: