title: Symfony2 login with md5 password
body: <p>Hello I'm trying to do a login with Symfony2 and database table with passwords in md5 with no salt field. I have a lot of users and I can't change it.</p>
  
  <p>The login seems to work fine when I send form with invalid email, it returns the message right "Bad credentials". But when I send form with good email it says "The presented password is invalid."</p>
  
  <p>What's wrong?</p>
  
  <p>I config the firewall:</p>
  
  <pre><code>security:
      encoders:
          Usuari\BackendBundle\Entity\Usuari:
              algorithm: md5
  </code></pre>
  
  <p>Implement UserInterface in Usuari entity, with no salt</p>
  
  <pre><code>    public function getUsername()
      {
          return $this-&gt;email;
      }
  
      public function getSalt() { 
          return '';
      }
  
      public function getPassword()
      {
          return $this-&gt;clau;
      }
  
      public function getRoles()
      {
          return array('ROLE_ADMIN');
      }
  
      public function eraseCredentials() { }
  
      public function equals(UserInterface $user)
      {
          return $this-&gt;email === $user-&gt;getUsername();
      }
  </code></pre>
  
  <p>And security controlles at /login route:</p>
  
  <pre><code>namespace Mes\BackendBundle\Controller;
  
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Symfony\Component\Security\Core\SecurityContext;
  
  
      class SecurityController extends Controller
      {
          public function loginAction()
          {
              $request = $this-&gt;getRequest();
              $session = $request-&gt;getSession();
  
              // get the login error if there is one
              if ($request-&gt;attributes-&gt;has(SecurityContext::AUTHENTICATION_ERROR)) {
                  $error = $request-&gt;attributes-&gt;get(SecurityContext::AUTHENTICATION_ERROR);
              } else {
                  $error = $session-&gt;get(SecurityContext::AUTHENTICATION_ERROR);
              }
  
              return $this-&gt;render('MeBackendBundle:Security:login.html.twig', array(
                  // last username entered by the user
                  'last_username' =&gt; $session-&gt;get(SecurityContext::LAST_USERNAME),
                  'error'         =&gt; $error,
              ));
          }
      }
      ?&gt;
  </code></pre>