当前位置: 首页>>代码示例>>PHP>>正文


PHP LightOpenID::validate方法代码示例

本文整理汇总了PHP中LightOpenID::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP LightOpenID::validate方法的具体用法?PHP LightOpenID::validate怎么用?PHP LightOpenID::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LightOpenID的用法示例。


在下文中一共展示了LightOpenID::validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loginFinish

 /**
  * {@inheritdoc}
  */
 function loginFinish()
 {
     # if user don't grant access of their data to your site, halt with an Exception
     if ($this->api->mode == 'cancel') {
         throw new Exception("Authentication failed! User has canceled authentication!", 5);
     }
     # if something goes wrong
     if (!$this->api->validate()) {
         throw new Exception("Authentication failed. Invalid request received!", 5);
     }
     # fetch received user data
     $response = $this->api->getAttributes();
     # store the user profile
     $this->user->profile->identifier = $this->api->identity;
     $this->user->profile->firstName = array_key_exists("namePerson/first", $response) ? $response["namePerson/first"] : "";
     $this->user->profile->lastName = array_key_exists("namePerson/last", $response) ? $response["namePerson/last"] : "";
     $this->user->profile->displayName = array_key_exists("namePerson", $response) ? $response["namePerson"] : "";
     $this->user->profile->email = array_key_exists("contact/email", $response) ? $response["contact/email"] : "";
     $this->user->profile->language = array_key_exists("pref/language", $response) ? $response["pref/language"] : "";
     $this->user->profile->country = array_key_exists("contact/country/home", $response) ? $response["contact/country/home"] : "";
     $this->user->profile->zip = array_key_exists("contact/postalCode/home", $response) ? $response["contact/postalCode/home"] : "";
     $this->user->profile->gender = array_key_exists("person/gender", $response) ? $response["person/gender"] : "";
     $this->user->profile->photoURL = array_key_exists("media/image/default", $response) ? $response["media/image/default"] : "";
     $this->user->profile->birthDay = array_key_exists("birthDate/birthDay", $response) ? $response["birthDate/birthDay"] : "";
     $this->user->profile->birthMonth = array_key_exists("birthDate/birthMonth", $response) ? $response["birthDate/birthMonth"] : "";
     $this->user->profile->birthYear = array_key_exists("birthDate/birthDate", $response) ? $response["birthDate/birthDate"] : "";
     if (isset($response['namePerson/friendly']) && !empty($response['namePerson/friendly']) && !$this->user->profile->displayName) {
         $this->user->profile->displayName = $response["namePerson/friendly"];
     }
     if (isset($response['birthDate']) && !empty($response['birthDate']) && !$this->user->profile->birthDay) {
         list($birthday_year, $birthday_month, $birthday_day) = $response['birthDate'];
         $this->user->profile->birthDay = (int) $birthday_day;
         $this->user->profile->birthMonth = (int) $birthday_month;
         $this->user->profile->birthYear = (int) $birthday_year;
     }
     if (!$this->user->profile->displayName) {
         $this->user->profile->displayName = trim($this->user->profile->firstName . " " . $this->user->profile->lastName);
     }
     if ($this->user->profile->gender == "f") {
         $this->user->profile->gender = "female";
     }
     if ($this->user->profile->gender == "m") {
         $this->user->profile->gender = "male";
     }
     // set user as logged in
     $this->setUserConnected();
     // with openid providers we get the user profile only once, so store it
     Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
 }
开发者ID:mif32,项目名称:2_d_social_login_lite,代码行数:52,代码来源:provider_model_openid.php

示例2: steamOauth

function steamOauth()
{
    $openid = new LightOpenID(SB_HOST);
    if (!$openid->mode) {
        $openid->identity = 'http://steamcommunity.com/openid';
        header("Location: " . $openid->authUrl());
        exit;
    } elseif ($openid->mode == 'cancel') {
        // User canceled auth.
        return false;
    } else {
        if ($openid->validate()) {
            $id = $openid->identity;
            $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
            preg_match($ptn, $id, $matches);
            if (!empty($matches[1])) {
                return $matches[1];
            }
            return null;
        } else {
            // Not valid
            return false;
        }
    }
}
开发者ID:gitter-badger,项目名称:SourceBans-Fork,代码行数:25,代码来源:steamopenid.php

示例3: openIDLogin

 /**
  * 處理 OpenID 登入
  * GET login/openid
  */
 public function openIDLogin()
 {
     try {
         // $openid = new LightOpenID('my-host.example.org');
         $openid = new LightOpenID('http://10.231.87.100:81/');
         if (!$openid->mode) {
             // 第一步驟
             // 設定
             $openid->identity = 'http://openid.ntpc.edu.tw/';
             // 要求取得之資料欄位
             $openid->required = array('namePerson', 'pref/timezone');
             // 會先到 輸入帳密登入頁面
             // 再到 同意 / 不同意 授權頁面
             return Redirect::to($openid->authUrl());
         } elseif ($openid->mode == 'cancel') {
             // 使用者取消(不同意授權)
             return Redirect::to('/');
             // 導回首頁
         } else {
             // 使用者同意授權
             // 此時 $openid->mode = "id_res"
             if ($openid->validate()) {
                 // 通過驗證,也同意授權
                 // 取得資料
                 $attr = $openid->getAttributes();
                 // return dd($attr);
                 // 將取得之資料帶到下一個步驟進行處理
                 // 要有相對應的路由設定
                 return Redirect::action('AuthController@showUserData', ['user' => $attr]);
             }
         }
     } catch (ErrorException $e) {
         echo $e->getMessage();
     }
 }
开发者ID:sandy7772266,项目名称:vote_1031,代码行数:39,代码来源:AuthController.php

示例4: steamlogin

function steamlogin()
{
    try {
        // Change 'localhost' to your domain name.
        $openid = new LightOpenID('example.com');
        if (!$openid->mode) {
            if (isset($_GET['login'])) {
                $openid->identity = 'http://steamcommunity.com/openid';
                header('Location: ' . $openid->authUrl());
            }
            echo "<form action=\"?login\" method=\"post\"> <input type=\"image\" src=\"http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_large_border.png\"></form>";
        } elseif ($openid->mode == 'cancel') {
            echo 'User has canceled authentication!';
        } else {
            if ($openid->validate()) {
                $id = $openid->identity;
                $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
                preg_match($ptn, $id, $matches);
                session_start();
                $_SESSION['steamid'] = $matches[1];
                header('Location: ' . $_SERVER['REQUEST_URI']);
            } else {
                echo "User is not logged in.\n";
            }
        }
    } catch (ErrorException $e) {
        echo $e->getMessage();
    }
}
开发者ID:4ung,项目名称:SteamAuthentication,代码行数:29,代码来源:steamauth.php

示例5: steamLogin

 public static function steamLogin()
 {
     if (!isset($_SESSION['steamId'])) {
         $openid = new LightOpenID('http://192.168.13.37/?/LoginRedirect/steamLogin');
         if (!$openid->mode && isset($_GET['login'])) {
             $openid->identity = 'http://steamcommunity.com/openid/?l=english';
             // This is forcing english because it has a weird habit of selecting a random language otherwise
             header('Location: ' . $openid->authUrl());
         } elseif ($openid->mode == 'cancel') {
             echo 'User has canceled authentication!';
         } elseif ($openid->validate()) {
             $id = $openid->identity;
             // identity is something like: http://steamcommunity.com/openid/id/76561197960435530
             // we only care about the unique account ID at the end of the URL.
             $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
             preg_match($ptn, $id, $matches);
             $_SESSION['steamId'] = $matches[1];
             // Looks like we have everything we need, so lets send him to userlanding
             return UserLanding::currentUserCheck();
         } else {
             echo "<a href='http://192.168.13.37/?/LoginRedirect/steamLogin'>Try again</a>";
         }
     } else {
         return UserLanding::currentUserCheck();
     }
 }
开发者ID:Carl-the-menace,项目名称:RoadToDevGlobal,代码行数:26,代码来源:LoginRedirect.class.php

示例6: getUserEmail

 public static function getUserEmail()
 {
     $encrypt_content = isset($_COOKIE[self::COOKIE_ID]) ? trim($_COOKIE[self::COOKIE_ID]) : null;
     if ($encrypt_content) {
         $content = self::decrypt($encrypt_content);
         list($email, $userName) = explode(self::USER_EMAIL_SPLITTER, $content);
         return array('email' => $email, 'userName' => $userName);
     }
     $openid = new LightOpenID($_SERVER['HTTP_HOST']);
     if (!$openid->mode) {
         $openid->identity = 'https://www.google.com/accounts/o8/id';
         $openid->required = array('contact/email', 'namePerson/first', 'namePerson/last');
         header('Location: ' . $openid->authUrl());
         die;
     } elseif ($openid->mode != 'cancel' && $openid->validate()) {
         $data = $openid->getAttributes();
         $email = $data['contact/email'];
         $userName = $data['namePerson/last'] . $data['namePerson/first'];
         $content = $email . self::USER_EMAIL_SPLITTER . $userName;
         $encrypt_content = self::encrypt($content);
         $_COOKIE[self::COOKIE_ID] = $encrypt_content;
         $expire = self::COOKIE_EXPIRE_TIME + time();
         setcookie(self::COOKIE_ID, $encrypt_content, $expire);
         return array('email' => $email, 'userName' => $userName);
     }
     return array();
 }
开发者ID:Rongya,项目名称:TeamToy-Plugins,代码行数:27,代码来源:OpenId.php

示例7: returningProvider

 /**
  * Service provider returns the user here.
  */
 public function returningProvider()
 {
     $openid = new LightOpenID('renshuu.paazmaya.com');
     if ($openid->mode) {
         $attr = $openid->getAttributes();
         if ($openid->validate()) {
             $_SESSION['email'] = $attr['contact/email'];
             // Not always set, specially Google, even if required...
             $_SESSION['username'] = isset($attr['namePerson']) ? $attr['namePerson'] : $attr['contact/email'];
             $_SESSION['identity'] = $openid->identity;
             // Check if the email has already existing access rights
             $sql = 'SELECT title, email, access FROM renshuu_user WHERE email = \'' . $_SESSION['email'] . '\'';
             $run = $this->pdo->query($sql);
             if ($run->rowCount() > 0) {
                 $res = $run->fetch(PDO::FETCH_ASSOC);
                 // So there was data, just login and use the site
                 $_SESSION['username'] = $res['title'];
                 $_SESSION['access'] = intval($res['access']);
                 // use as binary
             } else {
                 // Insert
                 $sql = 'INSERT INTO renshuu_user (title, email, identity, modified, access) VALUES (\'' . $attr['namePerson'] . '\', \'' . $attr['contact/email'] . '\', \'' . $openid->identity . '\', ' . time() . ', 1)';
                 $run = $this->pdo->query($sql);
                 $_SESSION['access'] = 1;
                 // Should you send an email telling about new user?
             }
         }
         header('Location: http://' . $_SERVER['HTTP_HOST']);
     }
 }
开发者ID:pazjacket,项目名称:paazmaya-_-renshuu.paazmaya.fi,代码行数:33,代码来源:RenshuuAuth.php

示例8: steamlogin

function steamlogin()
{
    try {
        require "settings.php";
        $openid = new LightOpenID($steamauth['domainname']);
        $button['small'] = "small";
        $button['large_no'] = "large_noborder";
        $button['large'] = "large_border";
        $button = $button[$steamauth['buttonstyle']];
        if (!$openid->mode) {
            if (isset($_GET['login'])) {
                $openid->identity = 'http://steamcommunity.com/openid';
                header('Location: ' . $openid->authUrl());
            }
            echo "<form action=\"?login\" method=\"post\"> <input class=\"design_login\" type=\"image\" src=\"img/Login.png\"></form>";
        } elseif ($openid->mode == 'cancel') {
            echo 'User has canceled authentication!';
        } else {
            if ($openid->validate()) {
                $id = $openid->identity;
                $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
                preg_match($ptn, $id, $matches);
                $_SESSION['steamid'] = $matches[1];
                if (isset($steamauth['loginpage'])) {
                    header('Location: index.php');
                }
            } else {
                echo "User is not logged in.\n";
            }
        }
    } catch (ErrorException $e) {
        echo $e->getMessage();
    }
}
开发者ID:gekt,项目名称:Alterisia,代码行数:34,代码来源:steamauth.php

示例9: register

 public function register(Application $app)
 {
     $app->before(function () use($app) {
         $app['session']->start();
         if ($app['request']->get('_route') == 'logout') {
             return;
         }
         if (!$app['session']->has('username')) {
             $openid = new \LightOpenID($_SERVER['SERVER_NAME']);
             if (!$openid->mode) {
                 $openid->identity = 'https://www.google.com/accounts/o8/id';
                 $openid->required = array('email' => 'contact/email', 'firstname' => 'namePerson/first', 'lastname' => 'namePerson/last');
                 return $app->redirect($openid->authUrl());
             } else {
                 if ($openid->validate()) {
                     $attributes = $openid->getAttributes();
                     $app['session']->set('username', $attributes['contact/email']);
                     $app['session']->set('fullname', $attributes['namePerson/first'] . ' ' . $attributes['namePerson/last']);
                 }
             }
         }
         $app['twig']->addGlobal('username', $app['session']->get('username'));
         $app['twig']->addGlobal('fullname', $app['session']->get('fullname'));
         if (isset($app['auth']) && !$app['auth']($app['session']->get('username'))) {
             $app['session']->remove('username');
             $app['session']->remove('fullname');
             return new Response($app['twig']->render('forbidden.html.twig'), 403);
         }
     });
 }
开发者ID:joska,项目名称:satisfy,代码行数:30,代码来源:SecurityServiceProvider.php

示例10: prepare

 public function prepare()
 {
     global $session;
     $this->template = '';
     if ($session->valid()) {
         $this->template = 'openid_success';
         return;
     }
     global $settings, $session;
     try {
         if (!isset($_GET['openid_mode'])) {
             $openid = new LightOpenID();
             $openid->identity = $settings['openid']['provider'];
             header('Location: ' . $openid->authUrl());
         } elseif ($_GET['openid_mode'] == 'cancel') {
             $this->template = 'openid_error';
         } else {
             $openid = new LightOpenID();
             if ($openid->validate()) {
                 $identity = $openid->identity;
                 $session->openid_login($identity);
                 //echo $identity;
                 //var_dump($session);
                 $this->template = 'openid_success';
                 global $SITE;
                 $SITE['head'] .= '<meta http-equiv="refresh" content="3;url=//tf2stats.net">';
             } else {
                 $this->template = 'openid_error';
             }
         }
     } catch (ErrorException $e) {
         $this->template = 'openid_error';
     }
 }
开发者ID:mwilchez,项目名称:master,代码行数:34,代码来源:login.view.php

示例11: getLogin

 public function getLogin()
 {
     if (!Auth::guest()) {
         return Redirect::action('HomeController@getIndex');
     }
     try {
         # Change 'localhost' to your domain name.
         $openid = new LightOpenID($_SERVER['HTTP_HOST']);
         if (!$openid->mode) {
             $openid->identity = 'http://steamcommunity.com/openid';
             return Redirect::to($openid->authUrl());
         } elseif ($openid->mode == 'cancel') {
             echo 'User has canceled authentication!';
         } else {
             if ($openid->validate()) {
                 $id = $openid->identity;
                 // identity is something like: http://steamcommunity.com/openid/id/76561197994761333
                 // we only care about the unique account ID at the end of the URL.
                 $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
                 preg_match($ptn, $id, $matches);
                 $steamid = $matches[1];
                 $this->fetch_username($steamid);
                 $this->fetch_backpack($steamid);
                 Auth::loginUsingId($steamid, true);
                 return Redirect::action('HomeController@getIndex');
             } else {
                 echo "User is not logged in.\n";
             }
         }
     } catch (ErrorException $e) {
         echo $e->getMessage();
     }
 }
开发者ID:TsunamiNori,项目名称:Raffles,代码行数:33,代码来源:SteamLoginController.php

示例12: validate

 /**
  * 向 OpenID Provider 驗證資料是否正確
  * 若正確則擷取資料
  * 
  * @return bool
  */
 public function validate()
 {
     if (parent::validate()) {
         $this->fetchUserDataFromOpenID();
         return true;
     }
     return false;
 }
开发者ID:t301000,项目名称:laravel-ntpc-openid,代码行数:14,代码来源:NtpcOpenid.php

示例13: index_openid_callback

function index_openid_callback()
{
    $openid = new LightOpenID();
    if ($openid->validate()) {
        return index_api_login($_GET['openid_identity']);
    } else {
        return index_login();
    }
}
开发者ID:jelmervdl,项目名称:wolk,代码行数:9,代码来源:index.php

示例14: LoadPage

 static function LoadPage($PageName, $Wrapper = true)
 {
     if (KERNEL::IsValidPage($PageName) == false) {
         KERNEL::OnError("Attempt to load invalid page '" . $PageName . "'");
     }
     if (!is_null(KERNEL::$Pages[$PageName][2])) {
         $Result = call_user_func(KERNEL::$Pages[$PageName][2]);
         if ($Result !== true) {
             KERNEL::OnError("Access Denied - " . $Result);
             die("");
             // Force cancel just incase
         }
     }
     if ($Wrapper) {
         global $GMDConfig;
         $OpenID = new LightOpenID($GMDConfig["Domain"]);
         if ($OpenID->validate()) {
             $ID = $OpenID->identity;
             $URL_Parts = explode("/", $ID);
             // Get their SteamID
             $CommunityID = $URL_Parts[sizeof($URL_Parts) - 1];
             $SteamID = CommunityToSteam($CommunityID);
             // Try and authenticate them
             $User = User::GetByField("User", "SteamID", $SteamID);
             if ($User->IsReal()) {
                 $User->AuthToUser();
             } else {
                 User::RegisterUser($SteamID, $_SERVER['REMOTE_ADDR'])->AuthToUser();
             }
             KERNEL::HardNavigate("home");
         } elseif ($_GET["page"] == "login") {
             if (User::$ActiveUser != false) {
                 if (isset($_GET["logout"])) {
                     User::Logout();
                 }
                 KERNEL::HardNavigate("home");
             } else {
                 $OpenID->identity = 'http://steamcommunity.com/openid';
                 header('Location: ' . $OpenID->authUrl());
             }
         }
         LightOpenID::revalidate();
     }
     global $OutputData;
     $OutputData = "";
     if ($Wrapper) {
         require "includes/util/header.php";
     }
     require "pages/" . $PageName . "/_process.php";
     require "pages/" . $PageName . "/_display.php";
     echo $OutputData;
     if ($Wrapper) {
         require "includes/util/footer.php";
     }
 }
开发者ID:Zipcore,项目名称:GMDonate,代码行数:55,代码来源:kernel.php

示例15: LoginButton

function LoginButton()
{
    if (isset($_POST['logout'])) {
        unset($_POST);
        session_destroy();
        return 'Logged out.';
    }
    if (!isset($_SESSION['sid']) && isset($_SERVER['REQUEST_METHOD'])) {
        try {
            // Change 'localhost' to your domain name.
            $openid = new LightOpenID('http://endgame.tf');
            //$openid = new LightOpenID('http://76.164.223.234');
            //elseif ( is_v4() ) $openid = new LightOpenID( 'http://65.111.166.150' );
            if (!$openid->mode) {
                if (isset($_GET['login'])) {
                    $openid->identity = 'http://steamcommunity.com/openid';
                    header('Location: ' . $openid->authUrl());
                }
                return '<form action="?login" method="post"><input class="steamlogin" type="image" src="img/sits.gif" alt="Login With Steam"></form>';
            } elseif ($openid->mode == 'cancel') {
                return 'User has canceled authentication!';
            } else {
                if ($openid->validate()) {
                    $id = $openid->identity;
                    // identity is something like: http://steamcommunity.com/openid/id/76561197994761333
                    // we only care about the unique account ID at the end of the URL.
                    $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
                    preg_match($ptn, $id, $matches);
                    if (strlen($matches[1]) < 16) {
                        return 'Invalid steamid.';
                    }
                    //echo "User is logged in (steamID: $matches[1])\n";
                    //session_start();
                    database_login((int) $matches[1]);
                    $_SESSION['sid'] = (int) $matches[1];
                    //This is where the user's steamID is set, IMPORTANT.
                    if (isset($_SESSION['sid']) && is_numeric($_SESSION['sid']) == TRUE && !isset($_SESSION['currentUserName'])) {
                        $playerURL = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" . AKey() . "&steamids=" . $_SESSION['sid'] . "&format=json";
                        $playerData = json_decode(get_data($playerURL), true);
                        $_SESSION['currentUserName'] = $playerData['response']['players'][0]['personaname'];
                        //addUser( $_SESSION['sid'] );
                        header("Location: " . "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
                    }
                } else {
                    return 'User is not logged in.';
                }
            }
        } catch (ErrorException $e) {
            return $e->getMessage();
        }
    } else {
        return '<form action="' . $_SERVER['PHP_SELF'] . '" method="post"><INPUT TYPE = "Submit" Name = "logout" VALUE = "Log out"></form>';
    }
}
开发者ID:aaronsnow123,项目名称:OpenEndgame,代码行数:54,代码来源:openid.php


注:本文中的LightOpenID::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。