Entity Provider: Encoder Not Configured for Account

I am trying to configure the login system using the Entity Entity provider, but I always get this error:

No encoder has been configured for account "Prefix\MainBundle\Entity\Admin" 

Here is my setup:

security.yml

 security: encoders: Prefix\MainBundle\Entity\Admin: algorithm: sha1 encode_as_base64: false iterations: 1 role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH ] providers: administrators: entity: { class: PrefixMainBundle:Admin, property: username } firewalls: administrators: pattern: ^/admin/ anonymous: ~ provider: administrators form_login: login_path: /admin/login check_path: /admin/login_check access_control: - { path: ^/admin/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/admin, roles: ROLE_ADMIN } 

I have an Entity created and implementing UserInterface, but I can't get it to work, it would be great if someone could shed some light on this.

+4
source share
1 answer

Move the provider under the form:

  form_login: login_path: /admin/login check_path: /admin/login_check provider: administrators 

I assume you have an error while trying to log in using the form.

And although this is not directly related, you should replace your entry paths with named routes.

+2
source

Source: https://habr.com/ru/post/1482007/


All Articles