/**
  * Event onAfterInitialise
  */
 public function onAfterInitialise()
 {
     // Don't do anything if MageBridge is not enabled
     if ($this->isEnabled() == false) {
         return false;
     }
     // Perform actions on the frontend
     $application = JFactory::getApplication();
     // Check for postlogin-cookie
     if (isset($_COOKIE['mb_postlogin']) && !empty($_COOKIE['mb_postlogin'])) {
         // If the user is already logged in, remove the cookie
         if (JFactory::getUser()->id > 0) {
             setcookie('mb_postlogin', '', time() - 3600, '/', '.' . JURI::getInstance()->toString(array('host')));
         }
         // Otherwise decrypt the cookie and use it here
         $data = MageBridgeEncryptionHelper::decrypt($_COOKIE['mb_postlogin']);
         if (!empty($data)) {
             $customer_email = $data;
         }
     }
     // Perform a postlogin if needed
     $post = $application->input->post->getArray();
     if (empty($post)) {
         $postlogin_userevents = $this->params->get('postlogin_userevents', 0) == 1 ? true : false;
         if (empty($customer_email)) {
             $customer_email = MageBridgeModelBridge::getInstance()->getSessionData('customer/email');
         }
         if (!empty($customer_email)) {
             MageBridge::getUser()->postlogin($customer_email, null, $postlogin_userevents);
         }
     }
 }
 /**
  * Event onAfterInitialise
  *
  * @access public
  * @param null
  * @return null
  */
 public function onAfterInitialise()
 {
     // Don't do anything if MageBridge is not enabled
     if ($this->isEnabled() == false) {
         return false;
     }
     // Perform actions on the frontend
     $application = JFactory::getApplication();
     if ($application->isSite()) {
         // Import the custom module helper - this is needed to make it possible to flush certain positions
         if ($this->getParam('override_modulehelper', 1) == 1 && class_exists('JModuleHelper') == false) {
             $component_path = JPATH_SITE . '/components/com_magebridge/';
             if (MageBridgeHelper::isJoomla15()) {
                 @(include_once $component_path . 'rewrite/joomla/application/module/helper.php');
             } else {
                 if (MageBridgeHelper::isJoomla16()) {
                     @(include_once $component_path . 'rewrite-16/joomla/application/module/helper.php');
                 } else {
                     if (MageBridgeHelper::isJoomla17()) {
                         @(include_once $component_path . 'rewrite-17/joomla/application/module/helper.php');
                     } else {
                         @(include_once $component_path . 'rewrite-25/joomla/application/module/helper.php');
                     }
                 }
             }
         }
     }
     // Check for postlogin-cookie
     if (isset($_COOKIE['mb_postlogin']) && !empty($_COOKIE['mb_postlogin'])) {
         // If the user is already logged in, remove the cookie
         if (JFactory::getUser()->id > 0) {
             setcookie('mb_postlogin', '', time() - 3600, '/', '.' . JURI::getInstance()->toString(array('host')));
         }
         // Otherwise decrypt the cookie and use it here
         $data = MageBridgeEncryptionHelper::decrypt($_COOKIE['mb_postlogin']);
         if (!empty($data)) {
             $customer_email = $data;
         }
     }
     // Perform a postlogin if needed
     $post = JRequest::get('post');
     if (empty($post)) {
         $postlogin_userevents = $this->getParams()->get('postlogin_userevents', 0) == 1 ? true : false;
         if (empty($customer_email)) {
             $customer_email = MageBridgeModelBridge::getInstance()->getMageConfig('customer/email');
         }
         if (!empty($customer_email)) {
             MageBridge::getUser()->postlogin($customer_email, null, $postlogin_userevents);
         }
     }
 }
Example #3
0
 /**
  * Method to make login an user
  */
 public function login()
 {
     // Fetch the user-email
     $user_email = MageBridgeEncryptionHelper::decrypt(JFactory::getApplication()->input->getString('token'));
     $application = JFactory::getApplication();
     // Perform a post-login
     $rt = MageBridge::getUser()->postlogin($user_email, null, true);
     // Determine the redirect URL
     $redirectUrl = base64_decode(JFactory::getApplication()->input->getString('redirect'));
     if (empty($redirectUrl)) {
         $redirectUrl = MageBridgeModelBridge::getMagentoUrl();
     }
     // Redirect
     $application->redirect($redirectUrl);
     $application->close();
 }
 private function authenticate($auth)
 {
     if (!empty($auth) && !empty($auth['api_user']) && !empty($auth['api_key'])) {
         $api_user = MageBridgeEncryptionHelper::decrypt($auth['api_user']);
         $api_key = MageBridgeEncryptionHelper::decrypt($auth['api_key']);
         if ($api_user != MagebridgeModelConfig::load('api_user')) {
             MageBridgeModelDebug::getInstance()->error('XML-RPC plugin: API-authentication failed: Username did not match');
         } elseif ($api_key != MagebridgeModelConfig::load('api_key')) {
             MageBridgeModelDebug::getInstance()->error('XML-RPC plugin: API-authentication failed: Key did not match');
         } else {
             MageBridgeModelDebug::getInstance()->notice('XML-RPC plugin: API-authentication succeeded');
             return true;
         }
     }
     return false;
 }
 /**
  * Helper method to authenticate this API call
  *
  * @param array $auth
  *
  * @return bool
  */
 private function authenticate($auth)
 {
     if (!empty($auth) && !empty($auth['api_user']) && !empty($auth['api_key'])) {
         $apiUser = MageBridgeEncryptionHelper::decrypt($auth['api_user']);
         $apiKey = MageBridgeEncryptionHelper::decrypt($auth['api_key']);
         if ($apiUser != MagebridgeModelConfig::load('api_user')) {
             $this->debug->error('JSON-RPC: API-authentication failed: Username "' . $apiUser . '" did not match');
         } else {
             if ($apiKey != MagebridgeModelConfig::load('api_key')) {
                 $this->debug->error('JSON-RPC: API-authentication failed: Key "' . $apiKey . '" did not match');
             } else {
                 return true;
             }
         }
     }
     return false;
 }
 public static function decrypt($string)
 {
     return MageBridgeEncryptionHelper::decrypt($string);
 }
 public static function decrypt($data)
 {
     return MageBridgeEncryptionHelper::decrypt($data);
 }