0

I have just implemented login functionality similar to this tutorial http://symfony.com/doc/current/cookbook/security/entity_provider.html , but when I try to log in, I get:

"There is no user provider for user "App\SomeBundle\Entity\User"" 

My repository implements required interface, user entity references to the repository and in security.yml I have defined provider like in example for custom entity provider. I'm lost why there is an error.

In security.yml I have:

security:
    encoders:
        \App\SomeBundle\Entity\User: sha512
        Symfony\Component\Security\Core\User\User: plaintext

    role_hierarchy:
        ...

    providers:
        main:
            entity: { class: AppSomeBundle:User }

    ...

Header of user entity:

    /**
     * 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
{

And header of repository:

class UserRepository extends EntityRepository implements UserProviderInterface
{

Thanks for help.

Petr Jirásek
  • 453
  • 1
  • 5
  • 17

1 Answers1

0

Try removing the leading \ from the encoder, and using the same class name in the provider statement.

This is from my own security configuration:

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:
ritter
  • 555
  • 4
  • 13
  • If I want to use Custom entity repository, I cannot use the property attribute according to the tutorial. Despite this change, there is the same error. – Petr Jirásek Sep 22 '13 at 09:24