Exemplo n.º 1
0
 /**
  * Recover password
  *
  * @param string $email     Profile email
  * @param string $requestID Request ID
  *
  * @return boolean
  */
 protected function doPasswordRecovery($email, $requestID)
 {
     $result = false;
     $profile = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->findByLogin($email);
     if (!isset($profile) || $profile->isAdmin()) {
         \XLite\Core\TopMessage::addError('There is no user with specified email address');
     } elseif ($profile->getPasswordResetKey() != $requestID || \XLite\Core\Converter::time() > $profile->getPasswordResetKeyDate()) {
         \XLite\Core\TopMessage::addError('Your "Password reset key" has expired. Please enter the email address associated with your user account to get a new "Password reset key".');
         $profile->setPasswordResetKey('');
         $profile->setPasswordResetKeyDate(0);
         $profile->update();
     } else {
         $pass = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->generatePassword();
         $profile->setPassword(\XLite\Core\Auth::encryptPassword($pass));
         $profile->setForceChangePassword(true);
         $profile->setPasswordResetKey('');
         $profile->setPasswordResetKeyDate(0);
         $result = $profile->update();
         if ($result) {
             $successfullyLogged = \XLite\Core\Auth::getInstance()->loginProfile($profile);
             if ($successfullyLogged) {
                 $profileCart = $this->getCart();
                 // We merge the logged in cart into the session cart
                 $profileCart->login($profile);
                 \XLite\Core\Database::getEM()->flush();
                 if ($profileCart->isPersistent()) {
                     $this->updateCart();
                     \XLite\Core\Event::getInstance()->exclude('updateCart');
                 }
             }
         }
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Login body
  *
  * @return void
  */
 protected function loginBody()
 {
     $this->profile = $this->performLogin();
     if (!$this->profile instanceof \XLite\Model\Profile) {
         $this->set('valid', false);
         $this->addLoginFailedMessage(\XLite\Core\Auth::RESULT_ACCESS_DENIED);
         \XLite\Logger::getInstance()->log(sprintf('Log in action is failed (%s)', \XLite\Core\Request::getInstance()->login), LOG_WARNING);
     } else {
         if (\XLite\Core\Request::getInstance()->returnURL) {
             $url = preg_replace('/' . preg_quote(\XLite\Core\Session::getInstance()->getName()) . '=([^&]+)/', '', \XLite\Core\Request::getInstance()->returnURL);
             $this->setReturnURL($url);
         }
         $profileCart = $this->getCart();
         if (!$this->getReturnURL()) {
             $url = $profileCart->isEmpty() ? \XLite\Core\Converter::buildURL() : \XLite\Core\Converter::buildURL('cart');
             $this->setReturnURL($url);
         }
         $this->setHardRedirect();
         // We merge the logged in cart into the session cart
         $profileCart->login($this->profile);
         \XLite\Core\Database::getEM()->flush();
         if ($profileCart->isPersistent()) {
             $this->updateCart();
             \XLite\Core\Event::getInstance()->exclude('updateCart');
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Perform redirect
  *
  * @param string $url Redirect URL OPTIONAL
  *
  * @return void
  */
 protected function redirect($url = null)
 {
     $location = $this->getReturnURL();
     if (!isset($location)) {
         $location = isset($url) ? $url : $this->getURL();
     }
     // filter FORM ID from redirect url
     // FIXME - check if it's really needed
     $action = $this->get('action');
     if (empty($action)) {
         $location = $this->filterXliteFormID($location);
     }
     \XLite\Core\Event::getInstance()->display();
     \XLite\Core\Event::getInstance()->clear();
     $location = $this->addCleanupCacheMark($location);
     \XLite\Core\Operator::redirect($location, $this->getRedirectMode(), $this->getParam(static::PARAM_REDIRECT_CODE));
 }
Exemplo n.º 4
0
 /**
  * Display content for the AJAX requests
  *
  * @param string $content Content to display
  *
  * @return void
  */
 protected function displayAJAXContent($content)
 {
     // Dispatch events
     \XLite\Core\Event::getInstance()->display();
     \XLite\Core\Event::getInstance()->clear();
     // Send headers. TODO: Should be one header sending point.
     \XLite\View\Controller::sendHeaders();
     // Display content
     echo '<h2 class="ajax-title-loadable">' . $this->getTitle() . '</h2>';
     echo '<div class="ajax-container-loadable">' . $content . '</div>';
     exit(0);
 }