Esempio n. 1
0
 /**
  * Initiates Shared Session
  */
 protected function initSharedSession()
 {
     $cookie_name = $this->getSharedSessionCookieName();
     if (isset($_COOKIE[$cookie_name])) {
         $data = $this->parseSignedRequest($_COOKIE[$cookie_name]);
         if ($data && !empty($data['domain']) && self::isAllowedDomain($this->getHttpHost(), $data['domain'])) {
             // good case
             $this->sharedSessionID = $data['id'];
             return;
         }
         // ignoring potentially unreachable data
     }
     // evil/corrupt/missing case
     $base_domain = $this->getBaseDomain();
     $this->sharedSessionID = md5(uniqid(mt_rand(), true));
     $cookie_value = $this->makeSignedRequest(array('domain' => $base_domain, 'id' => $this->sharedSessionID));
     $_COOKIE[$cookie_name] = $cookie_value;
     if (!headers_sent()) {
         $expire = time() + self::FBSS_COOKIE_EXPIRE;
         SugarApplication::setCookie($cookie_name, $cookie_value, $expire, '/', '.' . $base_domain, false, true);
     } else {
         // @codeCoverageIgnoreStart
         self::errorLog('Shared session ID cookie could not be set! You must ensure you ' . 'create the Facebook instance before headers have been sent. This ' . 'will cause authentication issues after the first request.');
         // @codeCoverageIgnoreEnd
     }
 }
Esempio n. 2
0
global $app_language, $sugar_config;
//we don't want the parent module's string file, but rather the string file specifc to this subpanel
global $current_language;
// Get the login page image
if (sugar_is_file('custom/include/images/sugar_md.png')) {
    $login_image = '<IMG src="custom/include/images/sugar_md.png" alt="Sugar" width="340" height="25">';
} else {
    $login_image = '<IMG src="include/images/sugar_md_open.png" alt="Sugar" width="340" height="25" style="margin: 5px 0;">';
}
$sugar_smarty->assign('LOGIN_IMAGE', $login_image);
// See if any messages were passed along to display to the user.
if (isset($_COOKIE['loginErrorMessage'])) {
    if (!isset($_REQUEST['loginErrorMessage'])) {
        $_REQUEST['loginErrorMessage'] = $_COOKIE['loginErrorMessage'];
    }
    SugarApplication::setCookie('loginErrorMessage', '', time() - 42000, '/');
}
if (isset($_REQUEST['loginErrorMessage'])) {
    if (isset($mod_strings[$_REQUEST['loginErrorMessage']])) {
        echo "<p align='center' class='error' > " . $mod_strings[$_REQUEST['loginErrorMessage']] . "</p>";
    } else {
        if (isset($app_strings[$_REQUEST['loginErrorMessage']])) {
            echo "<p align='center' class='error' > " . $app_strings[$_REQUEST['loginErrorMessage']] . "</p>";
        }
    }
}
$lvars = $GLOBALS['app']->getLoginVars();
$sugar_smarty->assign("LOGIN_VARS", $lvars);
foreach ($lvars as $k => $v) {
    $sugar_smarty->assign(strtoupper($k), $v);
}
 public function testsetCookie()
 {
     //execute the method and check that the method adds the key value pair to cookies array.
     SugarApplication::setCookie('key', 'value');
     $this->assertEquals('value', $_COOKIE['key']);
 }