Ejemplo n.º 1
0
 function startLogin()
 {
     $parameters = array("scope" => $this->scope, "access_type" => "offline");
     $optionals = array("scope", "access_type", "redirect_uri", "approval_prompt", "hd");
     foreach ($optionals as $parameter) {
         if (isset($this->config[$parameter]) && !empty($this->config[$parameter])) {
             $parameters[$parameter] = $this->config[$parameter];
         }
     }
     Social_Auth::redirect($this->api->authorizeUrl($parameters));
 }
Ejemplo n.º 2
0
 function startLogin()
 {
     $parameters = array("scope" => $this->scope, "redirect_uri" => $this->client, "display" => "popup");
     $optionals = array("scope", "redirect_uri", "display");
     foreach ($optionals as $parameter) {
         if (isset($this->config[$parameter]) && !empty($this->config[$parameter])) {
             $parameters[$parameter] = $this->config[$parameter];
         }
     }
     $url = $this->api->getLoginUrl($parameters);
     Social_Auth::redirect($url);
 }
Ejemplo n.º 3
0
 function startLogin()
 {
     $tokens = $this->api->requestToken($this->client);
     $this->request_tokens_raw = $tokens;
     if ($this->api->http_code != 200) {
         throw new Social_Exception("Auth failed! {$this->network_name} error: " . $this->errorMessageByStatus($this->api->http_code));
     }
     if (!isset($tokens["oauth_token"])) {
         throw new Social_Exception("Auth failed! {$this->network_name}: invalid oauth token.");
     }
     $this->setToken("request_token", $tokens["oauth_token"]);
     $this->setToken("request_token_secret", $tokens["oauth_token_secret"]);
     Social_Auth::redirect($this->api->authorizeUrl($tokens));
 }
Ejemplo n.º 4
0
 public static function init()
 {
     if (!Social_Client::$finish) {
         Social_Client::$finish = true;
         try {
             require_once realpath(dirname(__FILE__)) . "/Session.php";
             $session = new Social_Session();
             if (!$session->get("sa_config")) {
                 header("HTTP/1.0 404 Not Found");
                 die("Direct access not allowed");
                 Social_Logger::error("Direct access not allowed, ");
             }
             Social_Auth::init($session->get("sa_config"));
         } catch (Exception $e) {
             Social_Logger::error("Error occured while Social_Auth init");
             header("HTTP/1.0 404 Not Found");
             die("Error occured!");
         }
     }
 }
Ejemplo n.º 5
0
 function login()
 {
     Social_Logger::info("###Social_Adapter::login( {$this->network_name} ) ");
     if (!$this->adapter) {
         throw new Social_Exception("Social_Adapter::login() cannot be used directly");
     }
     foreach (Social_Auth::$config["networks"] as $network => $params) {
         Social_Auth::session()->deleteByKey("sa_session.{$network}.sa_callback");
         Social_Auth::session()->deleteByKey("sa_session.{$network}.sa_client");
         Social_Auth::session()->deleteByKey("sa_session.{$network}.network_params");
     }
     $this->logout();
     $social_auth_base_url = Social_Auth::$config["base_url"];
     $this->params["sa_token"] = session_id();
     $this->params["sa_time"] = time();
     $this->params["sa_login"] = $social_auth_base_url . (strpos($social_auth_base_url, '?') ? '&' : '?') . "sa_login={$this->network_name}&sa_time={$this->params["sa_time"]}";
     $this->params["sa_login_finish"] = $social_auth_base_url . (strpos($social_auth_base_url, '?') ? '&' : '?') . "sa_login_finish={$this->network_name}";
     Social_Auth::session()->set("sa_session.{$this->network_name}.sa_callback", $this->params["sa_callback_url"]);
     Social_Auth::session()->set("sa_session.{$this->network_name}.sa_client", $this->params["sa_login_finish"]);
     Social_Auth::session()->set("sa_session.{$this->network_name}.network_params", $this->params);
     Social_Auth::session()->set("sa_config", Social_Auth::$config);
     Social_Logger::debug("Social_Adapter::login( {$this->network_name} ), redirecting sa_login url.");
     Social_Auth::redirect($this->params["sa_login"]);
 }
Ejemplo n.º 6
0
    if (!session_start()) {
        throw new Exception("In order to use CometChat Social Authentication, you need to start session with 'session_start()'", 1);
    }
}
/**
 * Check if any error exists
 */
$error = "";
if (!empty($_GET["error"])) {
    $error = trim(strip_tags($_GET["error"]));
}
if (isset($_GET["network"]) && $_GET["network"]) {
    $config = dirname(__FILE__) . '/config.php';
    require_once dirname(__FILE__) . '/Social/Auth.php';
    try {
        $socialAuth = new Social_Auth($config);
        $network = trim(strip_tags($_GET["network"]));
        $adapter = $socialAuth->authenticate($network);
    } catch (Exception $e) {
        $error = $e->getMessage();
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">

    <title>CometChat Social Authentication</title>
    <!-- Custom Css Styles Start-->
    <style>
Ejemplo n.º 7
0
 public function getNetwork()
 {
     $networks = Social_Auth::getConnectedNetworks();
     foreach ($networks as $networkToLogout) {
         return $networkToLogout;
     }
 }
Ejemplo n.º 8
0
 public static function logout($network = null)
 {
     $networks = Social_Auth::getConnectedNetworks();
     if ($network) {
         $adapter = Social_Auth::getAdapter($network);
         $adapter->logout();
     } else {
         foreach ($networks as $networkToLogout) {
             $adapter = Social_Auth::getAdapter($networkToLogout);
             $adapter->logout();
         }
     }
 }
Ejemplo n.º 9
0
 public function clearTokens()
 {
     Social_Auth::session()->deleteByNetwork("sa_session.{$this->network_name}.");
 }
Ejemplo n.º 10
0
 function startLogin()
 {
     Social_Auth::redirect($this->api->authorizeUrl(array("scope" => $this->scope)));
 }
Ejemplo n.º 11
0
<?php

$config = dirname(__FILE__) . '/config.php';
require_once "Social/Auth.php";
try {
    $socialAuth = new Social_Auth($config);
    Social_Auth::session()->deleteByKey("SA_USER");
    @session_start();
    unset($_SESSION['cometchat']);
    if (!empty($_GET['callback'])) {
        echo $_GET['callback'] . '(' . json_encode(array(1)) . ')';
    } else {
        echo '1';
    }
} catch (Exception $ex) {
    echo "Error occured: " . $ex->getMessage();
}
Ejemplo n.º 12
0
<?php

$config = dirname(__FILE__) . '/config.php';
require_once "Social/Auth.php";
try {
    $socialAuth = new Social_Auth($config);
    if ($socialAuth->getNetwork() == 'facebook') {
        $logoutURL = 'https://www.facebook.com/logout.php?next=' . urlencode($_SERVER['HTTP_REFERER']) . '&access_token=' . urlencode($_SESSION['cometchat']['sa_fb_access_token']);
    } elseif ($socialAuth->getNetwork() == 'google') {
        $logoutURL = 'https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=' . urlencode($_SERVER['HTTP_REFERER']);
    } elseif ($socialAuth->getNetwork() == 'twitter') {
        $logoutURL = 'twitter';
    }
    Social_Auth::session()->deleteByKey("SA_USER");
    $socialAuth->logout();
    @session_start();
    unset($_SESSION['cometchat']);
    unset($_SESSION['basedata']);
    if (!empty($_GET['callback'])) {
        echo $_GET['callback'] . '(' . json_encode(array('logoutURL' => $logoutURL)) . ')';
    } else {
        echo json_encode(array('logoutURL' => $logoutURL));
    }
} catch (Exception $ex) {
    echo "Error occured: " . $ex->getMessage();
}
Ejemplo n.º 13
0
    if (!session_start()) {
        throw new Exception("In order to use CometChat Social Authentication, you need to start session with 'session_start()'", 1);
    }
}
/**
 * Check if any error exists
 */
$error = "";
if (!empty($_GET["error"])) {
    $error = trim(strip_tags($_GET["error"]));
}
if (isset($_GET["network"]) && $_GET["network"]) {
    $config = dirname(__FILE__) . '/config.php';
    require_once dirname(__FILE__) . '/Social/Auth.php';
    try {
        $socialAuth = new Social_Auth($config);
        $network = trim(strip_tags($_GET["network"]));
        $adapter = $socialAuth->authenticate($network);
    } catch (Exception $e) {
        $error = $e->getMessage();
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">

    <title>CometChat Social Authentication</title>
    <!-- Custom Css Styles Start-->
    <style>