我有一个带有sfGuardUser插件的symfony1应用程序。我需要在我的新symfony2应用程序中使用相同的数据库。
我应该如何定义密码编码器,使其与symfony1编码的密码相匹配?
发布于 2013-01-08 21:36:05
如果您没有提供不同的编码算法,那么Symfony 1.x将使用sha1($salt.$rawPassword)。所以你的PasswordEncoder应该是这样的:
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;
}
}祝好运!
https://stackoverflow.com/questions/14213053
复制相似问题