/** * Special processing before attribute save: * a) check some rules for password * b) transform temporary attribute 'password' into real attribute 'password_hash' * * @param Varien_Object $object */ public function beforeSave($object) { $password = $object->getPassword(); /** @var Mage_Core_Helper_String $stringHelper */ $stringHelper = Mage::helper('Mage_Core_Helper_String'); $length = $stringHelper->strlen($password); if ($length > 0) { if ($length < self::MIN_PASSWORD_LENGTH) { Mage::throwException(Mage::helper('Mage_Customer_Helper_Data')->__('The password must have at least %s characters.', self::MIN_PASSWORD_LENGTH)); } if ($stringHelper->substr($password, 0, 1) == ' ' || $stringHelper->substr($password, $length - 1, 1) == ' ') { Mage::throwException(Mage::helper('Mage_Customer_Helper_Data')->__('The password can not begin or end with a space.')); } $object->setPasswordHash($object->hashPassword($password)); } }