public function postAction()
 {
     $email = $this->_request->getParam('email');
     $response = $this->_helper->response();
     if (Kebab_Validation_Email::isValid($email)) {
         // Create user object
         $user = Doctrine_Core::getTable('Model_Entity_User')->findOneBy('email', $email);
         $password = Kebab_Security::createPassword();
         if ($user !== false) {
             $user->password = md5($password);
             $user->save();
             $configParam = Zend_Registry::get('config')->kebab->mail;
             $smtpServer = $configParam->smtpServer;
             $config = $configParam->config->toArray();
             // Mail phtml
             $view = new Zend_View();
             $view->setScriptPath(APPLICATION_PATH . '/views/mails/');
             $view->assign('password', $password);
             $transport = new Zend_Mail_Transport_Smtp($smtpServer, $config);
             $mail = new Zend_Mail('UTF-8');
             $mail->setFrom($configParam->from, 'Kebab Project');
             $mail->addTo($user->email, $user->fullName);
             $mail->setSubject('Reset Password');
             $mail->setBodyHtml($view->render('forgot-password.phtml'));
             $mail->send($transport);
             $response->setSuccess(true)->getResponse();
         } else {
             $response->addNotification(Kebab_Notification::ERR, 'There isn\'t user with this email')->getResponse();
         }
     } else {
         $response->addError('email', 'Invalid email format')->getResponse();
     }
 }
Ejemplo n.º 2
0
 /**
  * @static
  * @throws Doctrine_Exception|Zend_Exception
  * @param string $fullName
  * @param string $email
  * @param string $language
  * @return bool|Model_Entity_User
  */
 public static function invite($fullName, $email, $language = 'en')
 {
     $retVal = false;
     Doctrine_Manager::connection()->beginTransaction();
     try {
         $userSignUp = new Model_Entity_User();
         $userSignUp->fullName = $fullName;
         $userSignUp->email = $email;
         $userSignUp->language = $language;
         $userSignUp->activationKey = Kebab_Security::createActivationKey();
         $userSignUp->status = 'pending';
         $userSignUp->active = 0;
         $userSignUp->save();
         $retVal = $userSignUp;
         Doctrine_Manager::connection()->commit();
         unset($userSignUp);
     } catch (Zend_Exception $e) {
         Doctrine_Manager::connection()->rollback();
         throw $e;
     } catch (Doctrine_Exception $e) {
         Doctrine_Manager::connection()->rollback();
         throw $e;
     }
     return $retVal;
 }