关于MAGENTO中用户密码的验证

在做天下牧场项目时,对QQ快速登入的用户进行用户绑定功能,其中要绑定牧场用户时首先要验证邮箱是否纯在,再验证用户密码是否正确:
1,验证邮箱是否纯在:

    private function _checkEmailByQq($email)
    {
        if (preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/', $email) !== 1) {
            return false;
        }

        /* @var $customerModel Mage_Customer_Model_Customer */
        $customerModel = Mage::getModel('customer/customer');
        $customerModel->setData('website_id', Mage::app()->getWebsite()->getId());
        $customerModel->loadByEmail($email);

        return $customerModel->getId();
    }

2,验证密码是否正确:

        $websiteId = Mage::app()->getStore()->getWebsiteId();
        try {
            $login_customer_result = Mage::getModel('customer/customer')->setWebsiteId($websiteId)->authenticate($email, $password);
            $validate = 1;
        }
        catch(Exception $ex) {
            $validate = 0;
        }

其中如果$validate = 1
则密码验证正确

你可能感兴趣的:(关于MAGENTO中用户密码的验证)