/** * Forget password action * * 2-steps password restore: * * 1: confirm on password restoration sents to users' email * 2: if confirmed, new password generated and sends to user email * (forgetPwdConfirmAction) */ public function forgetPasswordAction() { $form = new Users_Form_Auth_Forget(); if ($this->_request->isPost()) { if ($form->isValid($this->_getAllParams())) { $user = $this->_manager->forgetPassword($form->getValue('email')); if ($user) { // send email Mail_Model_Mail::forgetPassword($user); $message = 'The confirmation email to reset your ' . 'password is sent. Please check your email '; $this->_flashMessenger->addMessage($message); $this->_helper->redirector->gotoRoute(array(), 'login'); } } else { // show errors $errors = $form->getErrors(); foreach ($errors as $fn => $error) { if (empty($error)) { continue; } $el = $form->getElement($fn); $dec = $el->getDecorator('HtmlTag'); $cls = $dec->getOption('class'); $dec->setOption('class', $cls . ' error'); } } } $this->view->form = $form; }