public function forgotpasswordAction() { $this->_helper->viewRenderer('forgotpasswordform'); $form = new Application_Form_Forgotpassword(); if ($form->isValid($this->getRequest()->getPost())) { $User = new Application_Model_DbTable_User(); $select = $User->select()->where('username = ?', $form->getValue('username')); $u = $User->fetchRow($select); $salt = My_Salt::getSalt(); $password = My_Salt::randomPassword(); $u->salt = $salt; $u->password = md5($password . $salt); $u->save(); $mail = new My_Mail_Gmail(); $mail->mailNewPassword($u->email, $password); return $this->_helper->redirector( 'index', 'index', 'default' ); } $this->view->form = $form; }
Listing 37.10. Kod akcji forgotpassword
Rozdział 37. Rejestracja użytkowników