Ejemplo n.º 1
0
 /**
  * Check login
  * @param EAPM $eapmBean
  * @see ExternalAPIBase::checkLogin()
  */
 public function checkLogin($eapmBean = null)
 {
     $reply = parent::checkLogin($eapmBean);
     if (!$reply['success']) {
         return $reply;
     }
     if ($this->checkOauthLogin()) {
         return array('success' => true);
     }
 }
Ejemplo n.º 2
0
 public function checkLogin($eapmBean = null)
 {
     if (!empty($eapmBean->url)) {
         $eapmBean->url = $this->fixUrl($eapmBean->url);
     }
     $reply = parent::checkLogin($eapmBean);
     if (!$reply['success']) {
         return $reply;
     }
     $doc = new SimpleXMLElement($this->getuser_xml);
     $this->addAuthenticationInfo($doc);
     $doc->body->bodyContent->webExId = $this->account_name;
     $reply = $this->postMessage($doc);
     return $reply;
 }
Ejemplo n.º 3
0
 public function checkLogin($eapmBean = null)
 {
     $reply = parent::checkLogin($eapmBean);
     if (!$reply['success']) {
         return $reply;
     }
     if (!$this->setupFacebookLib()) {
         // FIXME: Translate
         return array('success' => FALSE, 'errorMessage' => 'Facebook does not have the required libraries.');
     }
     $GLOBALS['log']->debug('Checking login.');
     if (empty($this->eapmBean->oauth_secret)) {
         // We must be saving, try re-authing
         $GLOBALS['log']->debug('We must be saving.');
         if (!empty($_REQUEST['session'])) {
             $_REQUEST['session'] = str_replace('"', '"', $_REQUEST['session']);
             $GLOBALS['log']->debug('Have a session from facebook: ' . $_REQUEST['session']);
             $fbSession = $this->fb->getSession();
             if (!empty($fbSession)) {
                 $GLOBALS['log']->debug('Have a VALID session from facebook:' . print_r($fbSession, true));
                 // Put a string in here so we can tell when it resets it.
                 $this->eapmBean->oauth_secret = 'SECRET';
                 $this->eapmBean->api_data = base64_encode(json_encode(array('fbSession' => $fbSession)));
                 $this->eapmBean->validated = 1;
                 $this->eapmBean->save();
                 return array('success' => true);
             } else {
                 // FIXME: Translate
                 $GLOBALS['log']->error('Have an INVALID session from facebook:' . print_r($fbSession, true));
                 return array('success' => false, 'errorMessage' => 'No authentication.');
             }
         } else {
             $callback_url = $GLOBALS['sugar_config']['site_url'] . '/index.php?module=EAPM&action=oauth&record=' . $this->eapmBean->id;
             $callback_url = $this->formatCallbackURL($callback_url);
             $loginUrl = $this->fb->getLoginUrl(array('next' => $callback_url, 'cancel' => $callback_url, 'req_perms' => 'read_stream,offline_access'));
             SugarApplication::redirect($loginUrl);
             return array('success' => false);
         }
     }
     return $reply;
 }