No encoder has been configured for account with fosUserBundle symfony2.1
Asked Answered
S

3

22

I have this error when I submit the connexion form (I use FOSUserBundle latest version) :

No encoder has been configured for account "MyApp\UtilisateurBundle\Entity\Utilisateur

here is my entity :

    <?php
namespace MyApp\UtilisateurBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
 * @ORM\Entity
 */
class Utilisateur extends BaseUser
{
    /**
    * @ORM\Id
    * @ORM\Column(type="integer")
    * @ORM\generatedValue(strategy="AUTO")
    */
    protected $id;
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
}

and here is my app/config/security.yml :

imports:
- { resource: "@MyAppFilmothequeBundle/Resources/config/security.yml" }

and here is my src/MyApp/FilmothequeBundle/Ressources/config/security.yml :

security:
providers:
    fos_userbundle:
        id: fos_user.user_manager

firewalls:
    main:
        pattern:      .*
        form_login:
            provider:       fos_userbundle
            login_path:     /myapp/login
            use_forward:    false
            check_path:     /myapp/login_check
            failure_path:   null
            default_target_path: /myapp
        logout:
            path:   /myapp/logout
            target: /myapp
        anonymous:    true

I followed this tutorial to doing that : http://j-place.developpez.com/tutoriels/php/ameliorez-vos-applications-developpees-avec-symfony2/#LVI-B-1

How can I achieve this? thank you in advance

Secondclass answered 28/11, 2012 at 9:50 Comment(0)
P
53

Try adding this to the security key in security.yml

encoders:
        FOS\UserBundle\Model\UserInterface: sha512

so it's

security:
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    providers:
        ...

    firewalls:
        ...
Punchboard answered 28/11, 2012 at 14:49 Comment(0)
C
3

I was getting this error on LexikJWTAuthenticationBundle.

It helps me (config/packages/security.yaml):

security:
    encoders:
      App\Entity\User:
        algorithm: bcrypt
Camarata answered 11/12, 2018 at 20:35 Comment(0)
C
2

You need juste add this code in the security.yml

    encoders:
        # use your user class name here
        App\Entity\User:
            # Use native password encoder
            # This value auto-selects the best possible hashing algorithm
            # (i.e. Sodium when available).
            algorithm: auto

Im use symfony 4.4

Working for me

Crater answered 26/5, 2020 at 17:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.