public function executeLostPassword() { if ($this->getRequest()->getMethod() == sfRequest::GET) { // display a form to send a new passord to the user } else { $loginNameOrEmail = trim($this->getRequestParameter('loginNameOrEmail')); // attend to retrieve user $user_private_data = UserPrivateData::retrieveByLoginNameOrEmail($loginNameOrEmail); // set success or error if ($user_private_data) { // successfuly retrieved $newpwd = UserPrivateData::generatePwd(); $user_private_data->setPassword_tmp($newpwd); $user_private_data->save(); $this->getRequest()->setAttribute('password', $newpwd); $this->getRequest()->setAttribute('login_name', $user_private_data->getLoginName()); $this->sendC2cEmail($this->getModuleName(), 'messageResetPassword', $this->__('lost password email title'), $user_private_data->getEmail()); $this->statsdIncrement('reset'); return $this->setNoticeAndRedirect('Your password has been reset, check your email', '@homepage'); } else { // failed $this->statsdIncrement('notfound'); return $this->setErrorAndRedirect('User not found, please retry', 'users/lostPassword'); } } }