Hybrid_Endpoint::authInit PHP Méthode

authInit() protected méthode

Initializes authentication
protected authInit ( )
    protected function authInit()
    {
        if (!$this->initDone) {
            $this->initDone = true;
            // Init Hybrid_Auth
            try {
                if (!class_exists("Hybrid_Storage", false)) {
                    require_once realpath(dirname(__FILE__)) . "/Storage.php";
                }
                if (!class_exists("Hybrid_Exception", false)) {
                    require_once realpath(dirname(__FILE__)) . "/Exception.php";
                }
                if (!class_exists("Hybrid_Logger", false)) {
                    require_once realpath(dirname(__FILE__)) . "/Logger.php";
                }
                $storage = new Hybrid_Storage();
                // Check if Hybrid_Auth session already exist
                if (!$storage->config("CONFIG")) {
                    throw new Hybrid_Exception("You cannot access this page directly.");
                }
                Hybrid_Auth::initialize($storage->config("CONFIG"));
            } catch (Exception $e) {
                Hybrid_Logger::error("Endpoint: Error while trying to init Hybrid_Auth: " . $e->getMessage());
                throw new Hybrid_Exception("Endpoint: Error while trying to init Hybrid_Auth: " . $e->getMessage(), $e->getCode(), $e);
            }
        }
    }

Usage Example

Exemple #1
0
 /**
  * define:endpoint step 3.1 and 3.2
  */
 public static function processAuthDone()
 {
     Hybrid_Endpoint::authInit();
     // Fix a strange behavior when some provider call back ha endpoint
     // with /index.php?hauth.done={provider}?{args}...
     if (strrpos($_SERVER["QUERY_STRING"], '?')) {
         $_SERVER["QUERY_STRING"] = str_replace("?", "&", $_SERVER["QUERY_STRING"]);
         parse_str($_SERVER["QUERY_STRING"], Hybrid_Endpoint::$request);
     }
     $provider_id = trim(strip_tags(Hybrid_Endpoint::$request["hauth_done"]));
     $hauth = Hybrid_Auth::setup($provider_id);
     if (!$hauth) {
         Hybrid_Logger::error("Endpoint: Invalide parameter on hauth_done!");
         $hauth->adapter->setUserUnconnected();
         header("HTTP/1.0 404 Not Found");
         die("Invalide parameter! Please return to the login page and try again.");
     }
     try {
         Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() ");
         $hauth->adapter->loginFinish();
     } catch (Exception $e) {
         Hybrid_Logger::error("Exception:" . $e->getMessage(), $e);
         Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e);
         $hauth->adapter->setUserUnconnected();
     }
     Hybrid_Logger::info("Endpoint: job done. retrun to callback url.");
     $hauth->returnToCallbackUrl();
     die;
 }
All Usage Examples Of Hybrid_Endpoint::authInit