title: FOSUserBundle/Symfony3: Check current password before changing it
body: <p>I am using Symfony3 and FOSUserBundle. </p>
  
  <p>I am trying to create an action which will allow my users to change their password when they are already logged in.</p>
  
  <p>I am asking them to input their OLD password and new the NEW desired password and I want to check is the OLD password is the same with the password currently on record. </p>
  
  <p>For some bizarre reason the encoder keeps on returning the wrong hash. What am I doing wrong here? </p>
  
  <pre><code>    $user = $this-&gt;getUser();
      $newPasswordPlain = 'newpassword';
      $currentPasswordForValidation = 'test';
  
      $encoder_service = $this-&gt;get('security.encoder_factory');
      $encoder = $encoder_service-&gt;getEncoder($user);
      $encodedPassword = $encoder-&gt;encodePassword($currentPasswordForValidation, $user-&gt;getSalt());
  
      var_dump( $encodedPassword);
      var_dump( $user-&gt;getPassword());
  
      if ( $user-&gt;getPassword() == $encodedPassword ) {
          $userManager = $this-&gt;container-&gt;get('fos_user.user_manager');
          $user-&gt;setPlainPassword($newPasswordPlain);
          $userManager-&gt;updateUser($user, true);
      } else {
          var_dump('error: not the same password'); exit;
      }
  </code></pre>