/** * Validate password with salted hash * * @param string $password * @return boolean */ public function validatePassword($password) { // TODO Make a more secure method of bypassing password (PSE-27) if(Mage::getSingleton('engage/session')->getLoginRequest()===true){ Mage::getSingleton('engage/session')->setLoginRequest(false); return true; } return parent::validatePassword($password); }
/** * Synchronise a Magento customer with WordPress * * @param Mage_Customer_Model_Customer $customer * @return bool */ public function synchroniseCustomer(Mage_Customer_Model_Customer $customer) { $email = $customer->getEmail(); if ($customer->getCsData() && $customer->getCsData()->getEmail()) { $email = $customer->getCsData()->getEmail(); } $user = Mage::getModel('wordpress/user')->loadByEmail($email); if (!$user->getId() && !$customer->getPassword()) { return false; } $user->setUserEmail($customer->getEmail())->setUserRegistered($customer->getCreatedAt())->setUserNicename($customer->getName())->setDisplayName($customer->getFirstname())->setFirstName($customer->getFirstname())->setLastName($customer->getLastname())->setNickname($customer->getFirstname()); if (!$user->getUserLogin() || strpos($user->getUserLogin(), '@') !== false) { $user->setUserLogin($customer->getEmail()); } try { if ($customer->hasPassword()) { if ($customer->validatePassword($customer->getPassword())) { $wpHash = $this->hashPasswordForWordPress($customer->getPassword()); if ($this->isValidWordPressPassword($customer->getPassword(), $wpHash)) { $user->setUserPass($wpHash); } } } $user->save(); $customer->setWordpressUser($user); } catch (Exception $e) { Mage::helper('wordpress')->log($e); } }