Skip to content

Instantly share code, notes, and snippets.

@tiagosampaio
Last active December 5, 2017 00:27
Show Gist options
  • Save tiagosampaio/66f3506acd3fc8a87d915e54d64fc1a8 to your computer and use it in GitHub Desktop.
Save tiagosampaio/66f3506acd3fc8a87d915e54d64fc1a8 to your computer and use it in GitHub Desktop.
Code Example Customer Model in Magento 1.9.3.1
<?php
/**
* Authenticate customer
*
* @param string $login
* @param string $password
* @throws Mage_Core_Exception
* @return true
*
*/
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)) {
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;
}
/**
* Load customer by email
*
* @param string $customerEmail
* @return Mage_Customer_Model_Customer
*/
public function loadByEmail($customerEmail)
{
$this->_getResource()->loadByEmail($this, $customerEmail);
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment