Exemplo n.º 1
0
 /**
  * callback.
  *
  * @return	void
  */
 public function callback()
 {
     // CSRF prevention disabled, we are trusting in code authentication
     /*
     if ($this->csrfProtection)
     {
     	$this->_csrfProtection();
     }
     */
     try {
         // $channelId = $this->input->getUint('channelId');
         $session = JFactory::getSession();
         $channelId = $session->get('channelId');
         // Invalidating
         $session->set('channelId', false);
         $gpluscode = $this->input->getVar('code');
         $logger = AutotweetLogger::getInstance();
         $logger->log(JLog::INFO, 'GplusChannels callback: ' . $gpluscode);
         // Error throw
         if (!empty($gpluscode)) {
             $channel = F0FTable::getAnInstance('Channel', 'AutoTweetTable');
             $result = $channel->load($channelId);
             if (!$result) {
                 $msg = 'Channel failed to load!';
                 $logger->log(JLog::ERROR, $msg);
                 throw new Exception($msg);
             }
             $gplusChannelHelper = new GplusChannelHelper($channel);
             $gplusChannelHelper->authenticate($gpluscode);
             // Redirect
             $url = 'index.php?option=com_autotweet&view=channels&task=edit&id=' . $channelId;
             $this->setRedirect($url);
             $this->redirect();
         }
     } catch (Exception $e) {
         $logger = AutotweetLogger::getInstance();
         $logger->log(JLog::ERROR, $e->getMessage());
         throw $e;
     }
 }