/** * Supress forgot password action if disabled * * @see Mage_Customer_AccountController::forgotPasswordAction */ public function forgotPasswordPostAction() { if (!Mage::helper('privatesales')->canShowForgotPassword()) { $this->_getSession()->addError(Mage::helper('privatesales')->getForgotPasswordErrorMessage()); $this->_redirect('*/*'); return; } return parent::forgotPasswordPostAction(); }
public function forgotPasswordPostAction() { $params = $this->getRequest()->getParams(); if (isset($params['le_ajaxlogin']) && $params['le_ajaxlogin']) { $email = (string) $this->getRequest()->getPost('email'); if ($email) { $success = false; $message = ''; $error_type = ''; $error = false; if (isset($params['captcha'])) { $_captcha = Mage::getModel('customer/session')->getData('le_captcha_forgotpass_word'); if ($_captcha['data'] != $params['captcha']['le_captcha_forgotpass']) { $message = Mage::helper('ajaxlogin')->__('Incorrect CAPTCHA.'); $error_type = 'captcha'; $error = true; } } if ($error == false) { $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email); if ($customer->getId()) { try { $newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken(); $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken); $customer->sendPasswordResetConfirmationEmail(); $success = true; $message = Mage::helper('customer')->__('If there is an account associated with %s you will receive an email with a link to reset your password.', Mage::helper('customer')->htmlEscape($email)); } catch (Exception $exception) { $message = $exception->getMessage(); } } else { $message = Mage::helper('customer')->__('If there is an account associated with %s you will receive an email with a link to reset your password.', Mage::helper('customer')->htmlEscape($email)); $error_type = 'email'; } } $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('success' => $success, 'message' => $message, 'error_type' => $error_type))); } } else { return parent::forgotPasswordPostAction(); } }