I have a symfony1 application with sfGuardUser plugin. I need to use the same database in my new symfony2 application.
How should I define the password encoder so it match the symfony1 encoded passwords?
If you didn't provide a different encoding algorithm back then Symfony 1.x would use sha1($salt.$rawPassword). So your PasswordEncoder should look like this:
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
class PasswordEncoder implements PasswordEncoderInterface
{
public function encodePassword($raw, $salt)
{
return sha1($salt.$raw);
}
public function isPasswordValid($encoded, $raw, $salt)
{
return $this->encodePassword($raw, $salt) === $encoded;
}
}
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With