private function insertUser($formData) { $db = Zend_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { $emailConfirmationId = md5(uniqid()); $entity = array('username' => $formData['username'], 'password' => md5($formData['password']), 'email' => $formData['email'], 'email_confirmation_id' => $emailConfirmationId, 'entry_date' => new Zend_Db_Expr('NOW()')); $user = new Default_Dao_User(); $userId = $user->insert($entity); $mail = new Default_Helper_Mail($formData['email'], '', 'Detager: activate your account', 'registrationConfirmation.phtml'); $mail->emailConfirmationId = $emailConfirmationId; $mail->send(); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } }
public function indexAction() { $form = new Default_Form_ForgotPassword(); $this->view->form = $form; if ($this->getRequest()->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $emailConfirmationId = md5(uniqid()); $db = Zend_Db_Table::getDefaultAdapter(); $userTable = new Default_Dao_User(); $updatedRowsCount = $userTable->update(array('email_confirmation_id' => $emailConfirmationId), array($db->quoteInto('email = ?', $formData['email']), 'valid is true')); if ($updatedRowsCount == 1) { $mail = new Default_Helper_Mail($formData['email'], '', 'Detager: change password request', 'changePasswordInstructions.phtml'); $mail->emailConfirmationId = $emailConfirmationId; $mail->send(); } $this->render('confirm'); } } }