title: Symfony 3 Bad credentials while login
body: <p>I got a problem setting up a login with Symfony 3.
  I don't use FOSUserBundle because I need to log with the email only. I've been trying to create an user through my controller, it's working fine and add my user in my DB, but the authentification always show me the "Bad credentials" error.</p>
  
  <p>Here is my User entity :</p>
  
  <pre><code>&lt;?php
  namespace GR\UserBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Security\Core\User\UserInterface;
  
  /**
   * @ORM\Table(name="utilisateur")
   * @ORM\Entity(repositoryClass="GR\UserBundle\Repository\UserRepository")
   */
  class User implements UserInterface {
  
      /**
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @ORM\Column(name="nom", type="string", length=255)
       */
      private $nom;
  
      /**
       * @ORM\Column(name="telephone", type="string", length=255, nullable=true)
       */
      private $telephone;
  
      /**
       * @ORM\Column(name="email", type="string", length=255, unique=true)
       */
      private $email;
  
      /**
       * @ORM\Column(name="password", type="string", length=255)
       */
      private $password;
  
      /**
       * @ORM\Column(name="salt", type="string", length=255)
       */
      private $salt = '';
  
      /**
       * @ORM\Column(name="roles", type="array")
       */
      private $roles = array();
  
      /**
       * @ORM\ManyToOne(targetEntity="GR\BackOfficeBundle\Entity\Client", inversedBy="utilisateurs")
       */
      private $client;
  
      //getters &amp; setters + UserInterface empty methods
  </code></pre>
  
  <p>Here is my security.yml file :</p>
  
  <pre><code>security:
  
      encoders:
          GR\UserBundle\Entity\User:
              algorithm: sha512
  
      role_hierarchy:
          ROLE_ADMIN: [ROLE_OPERATEUR, ROLE_COLLABORATEUR]
          ROLE_OPERATEUR: ROLE_COLLABORATEUR
          ROLE_COLLABORATEUR: ROLE_USER
          ROLE_DESTINATAIRE: ROLE_USER
      # http://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
      providers:
          back_office:
              entity:
                  class: GR\UserBundle\Entity\User
                  property: email
      firewalls:
          # disables authentication for assets and the profiler, adapt it according to your needs
          dev:
              pattern: ^/(_(profiler|wdt)|css|images|js)/
              security: false
  
          back_office_login:
              pattern: ^/back-office/login$
              anonymous: true
              provider: back_office
              form_login:
                  login_path: gr_bo_login
                  check_path: gr_bo_login_check
                  default_target_path: gr_bo_home
  
          back_office:
              pattern: ^/back-office
              anonymous: false
              provider: back_office
              form_login:
                  login_path: gr_bo_login
                  check_path: gr_bo_login_check
                  default_target_path: gr_bo_home
              logout:
                  path: gr_bo_logout
                  target: gr_bo_login
              remember_me:
                  secret: "%secret%"
  </code></pre>
  
  <p>Here is my login form :</p>
  
  <pre><code>{% extends "GRUserBundle::layout.html.twig" %}
  
  {% block log_content %}
      {% if error %}
          &lt;div class="alert alert-danger"&gt;{{ error.message }}&lt;/div&gt;
      {% endif %}
  
      &lt;form action="{{ path('gr_bo_login_check') }}" method="post"&gt;
          &lt;label for="email"&gt;Email :&lt;/label&gt;
          &lt;input type="email" id="email" name="_email" /&gt;
  
          &lt;label for="password"&gt;Mot de passe :&lt;/label&gt;
          &lt;input type="password" id="password" name="_password" /&gt;
          &lt;br /&gt;
          &lt;input type="submit" value="Connexion" /&gt;
      &lt;/form&gt;
  {% endblock %}
  </code></pre>
  
  <p>And here is what I did to create my user :</p>
  
  <pre><code>$user = new User();
  
  $user-&gt;setNom('Test');
  $user-&gt;setEmail('admin@admin.fr');
  $user-&gt;setRoles(array('ROLE_ADMIN'));
  $user-&gt;setPassword('admin');
  $encoder = $this-&gt;container-&gt;get('security.password_encoder');
  $encoded = $encoder-&gt;encodePassword($user, $user-&gt;getPassword());
  $user-&gt;setPassword($encoded);
  
  $em = $this-&gt;getDoctrine()-&gt;getManager();
  $em-&gt;persist($user);
  $em-&gt;flush();
  </code></pre>
  
  <p>I encoded my user password according to <a href="http://symfony.com/doc/current/security/password_encoding.html" rel="nofollow noreferrer">this doc</a></p>
  
  <p>In my DB, the user created is like this :</p>
  
  <pre><code>id: 4
  client_id : null
  nom : Test
  telephone: null
  email : admin@admin.fr
  password : nhDr7OyKlXQju+Ge/WKGrPQ9lPBSUFfpK+B1xqx/+8zLZqRNX0+5G1zBQklXUFy86lCpkAofsExlXiorUcKSNQ==
  salt: 
  roles: a:1:{i:0;s:10:"ROLE_ADMIN";}
  </code></pre>
  
  <p>Now I don't know what to do, what can I try to make this works?</p>