本文整理汇总了PHP中Mage_Customer_Model_Customer::authenticate方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Customer_Model_Customer::authenticate方法的具体用法?PHP Mage_Customer_Model_Customer::authenticate怎么用?PHP Mage_Customer_Model_Customer::authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Customer_Model_Customer
的用法示例。
在下文中一共展示了Mage_Customer_Model_Customer::authenticate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
/**
* Customer authentication
*
* @param string $username
* @param string $password
* @return bool
*/
public function authenticate($username, $password)
{
// Try to authenticate this user using the normal Magento way
$rt = false;
try {
$rt = parent::authenticate($username, $password);
} catch (Exception $e) {
$rt = false;
}
// Continue when Joomla! Authentication is enabled
if ($rt == false && Mage::helper('magebridge')->allowJoomlaAuth() == true) {
Mage::getSingleton('magebridge/debug')->notice('Calling Joomla! authentication through API for customer ' . $username);
// Perform the actual call through RPC to Joomla!
$api_result = Mage::getSingleton('magebridge/client')->call('magebridge.login', array($username, $password));
if (is_array($api_result) && !empty($api_result)) {
// Load the customer
$customer = Mage::getModel('customer/customer');
$customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
if (!empty($api_result['email'])) {
$customer->loadByEmail($api_result['email']);
} else {
$customer->loadByEmail($username);
}
// Create this customer-record if it does not yet exist
if (!$customer->getId() > 0) {
// Load a basic record
$customer->setEmail($username);
$customer->setPassword($password);
$customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
$customer->setId(null);
$customer->save();
// Load the full record
$customer->setEmail($username);
$customer = Mage::getModel('customer/customer')->load($customer->getId());
$customer->setConfirmation(null);
$customer->save();
// Remember that Magento authentication failed, so reset the password
} else {
$customer->changePassword($password);
$customer->setConfirmation(null);
$customer->save();
}
// Load the current customer-object with the details we have so far
$this->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
$this->loadByEmail($customer->getEmail());
// Now the customer exists, so try again
Mage::dispatchEvent('customer_customer_authenticated', array('model' => $this, 'password' => $password));
$rt = true;
}
}
if ($rt != true) {
throw Mage::exception('Mage_Core', Mage::helper('customer')->__('Authentication failed.'), self::EXCEPTION_INVALID_EMAIL_OR_PASSWORD);
}
return $rt;
}
示例2: authenticate
public function authenticate($login, $password)
{
if (!$this->_helper->isEnabled()) {
return parent::authenticate($login, $password);
}
$this->loadByEmail($login);
if (!$this->getId()) {
return parent::authenticate($login, $password);
}
$this->_handleUnlock();
if ($this->getIsLocked()) {
throw Mage::exception('Mage_Core', $this->_helper->__('This account is locked because of too much unsuccessful login tries.'), self::EXCEPTION_TOO_MUCH_UNSUCCESSFUL_LOGIN_TRIES);
}
try {
parent::authenticate($login, $password);
$this->_resetLock();
return true;
} catch (Mage_Core_Exception $e) {
if ($e->getCode() === self::EXCEPTION_INVALID_EMAIL_OR_PASSWORD) {
$this->_handleLock();
}
throw $e;
}
}