public function forgotPasswordAction() { $this->view->pageHeading = "Forgot Password"; $request = $this->getRequest(); $this->view->form = $form = new Application_Form_Login(); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); $element->removeDecorator('Errors'); } $form->removeElement('password'); if ($request->isPost()) { if ($form->isValid($request->getPost())) { $params = $request->getParams(); $user = new Application_Model_User(); $user = $user->fetchRow("email='{$params['email']}'"); if ($user) { $auth = new Base_Auth_Auth(); $auth->recoverPassword($user); $this->_flashMessenger->addMessage(array('success' => 'Your password has been reset. Please check your email.')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/index/login')); } else { $this->_flashMessenger->addMessage(array('error' => "Invalid email address!")); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/index/forgot-password')); } } else { $this->view->email_msg = array_pop($form->getMessages('email')); } } }
public function forgotAction() { $request = $this->getRequest(); $this->view->form = $form = new Application_Form_Forgot(); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); } $options = $request->getParams(); if ($request->isPost()) { if ($form->isValid($request->getPost())) { $model = new Application_Model_User(); $model = $model->fetchRow("email='{$options['email']}'"); if (false !== $model) { $Auth = new Base_Auth_Auth(); $Auth->recoverPassword($model); //$this->view->msg="Your password has been reset and emailed to your email address."; $msgNs = new Zend_Session_Namespace("app"); $msgNs->message = "Your password has been reset and emailed to your email address."; $form->reset(); return $this->_helper->redirector('forgot', 'index', "default"); } } } $msgNs = new Zend_Session_Namespace("app"); $this->view->msg = $msgNs->message; $msgNs->message = ""; }
public function resetPasswordAction() { $id = $this->_getParam('id'); $User = new Application_Model_User(); $res = $User->find($id); $Auth = new Base_Auth_Auth(); $Auth->recoverPassword($res); return $this->_helper->redirector('index', 'user', "admin", array('msg' => base64_encode("User [Id : {$res->getId()}] Password has been changed!"))); }