将Laravel用户密码导入Magento密码


Import Laravel user passwords to Magento passwords

我正在将一个电子商务应用程序从Laravel转移到Magento。Laravel应用程序使用Laravel的默认密码哈希,据我所知,它使用Bcrypt。

Magento客户导入让你导入密码散列,但我认为Magento使用MD5。当然,当用户尝试登录时,Magento会将MD5哈希与Bcrypt哈希进行比较。

有人知道这方面的办法吗?是否可以将Magento设置为使用与Laravel相同的Bcrypt哈希?或者以其他方式将Laravel散列"转换"为Magento可以理解的东西?

非常感谢

扩展客户模型"Mage_Customer_model_Customer"并写下如下内容:

class Namespace_Modulename_Model_Customer_Customer extends Mage_Customer_Model_Customer
{
    public function authenticate($login, $password)
    {
        $this->loadByEmail($login);
        if ($this->getConfirmation() && $this->isConfirmationRequired()) {
            throw Mage::exception('Mage_Core', Mage::helper('customer')->__('This account is not confirmed.'),
                self::EXCEPTION_EMAIL_NOT_CONFIRMED
            );
        }
        if (!$this->validatePassword($password)) {
            $hash=$this->getPasswordHash();
            if(!$this->YourCustomFunctionForPasswordCheck($password,$hash))
            {
                throw Mage::exception('Mage_Core', Mage::helper('customer')->__('Invalid login or password.'),
                    self::EXCEPTION_INVALID_EMAIL_OR_PASSWORD
                );
            }
        }
        Mage::dispatchEvent('customer_customer_authenticated', array(
           'model'    => $this,
           'password' => $password,
        ));
        return true;
    }
    public function YourCustomFunctionForPasswordCheck($password, $hash)
    {
        //Custom code for password check like Laravel.
    }
}