當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LightOpenID::authUrl方法代碼示例

本文整理匯總了PHP中LightOpenID::authUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP LightOpenID::authUrl方法的具體用法?PHP LightOpenID::authUrl怎麽用?PHP LightOpenID::authUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在LightOpenID的用法示例。


在下文中一共展示了LightOpenID::authUrl方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: LightOpenID

 function action_tryAuth()
 {
     $type = $_POST['type'];
     if (isset($_GET['openid_mode']) && $_GET['openid_mode'] == 'cancel') {
         $this->request->redirect('auth/login');
         return;
     }
     $openid = new LightOpenID();
     $openid->returnUrl = url::site('auth/finishAuth', TRUE);
     $openid->required = array('namePerson/friendly', 'contact/email', 'namePerson/first', 'namePerson/last', 'namePerson');
     if ($type == 'google') {
         $openid->identity = 'https://www.google.com/accounts/o8/id';
         $url = $openid->authUrl(TRUE);
     } else {
         if ($type == 'yahoo') {
             $openid->identity = 'https://me.yahoo.com';
         } else {
             /* FIXME - flash error message - no type provided*/
             $this->request->required('auth/login');
         }
     }
     if (!isset($url)) {
         $url = $openid->authUrl();
     }
     $this->request->redirect($url);
 }
開發者ID:halkeye,項目名稱:tops,代碼行數:26,代碼來源:auth.php

示例2: loginBegin

 /**
  * {@inheritdoc}
  */
 function loginBegin()
 {
     if (empty($this->openidIdentifier)) {
         throw new Exception("OpenID adapter require the identity provider identifier 'openid_identifier' as an extra parameter.", 4);
     }
     $this->api->identity = $this->openidIdentifier;
     $this->api->returnUrl = $this->endpoint;
     $this->api->required = array('namePerson/first', 'namePerson/last', 'namePerson/friendly', 'namePerson', 'contact/email', 'birthDate', 'birthDate/birthDay', 'birthDate/birthMonth', 'birthDate/birthYear', 'person/gender', 'pref/language', 'contact/postalCode/home', 'contact/city/home', 'contact/country/home', 'media/image/default');
     # redirect the user to the provider authentication url
     Hybrid_Auth::redirect($this->api->authUrl());
 }
開發者ID:mif32,項目名稱:2_d_social_login_lite,代碼行數:14,代碼來源:provider_model_openid.php

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: loginAction

 public function loginAction()
 {
     $provider = $this->getRequest()->getParam('provider');
     if ($provider) {
         try {
             require_once 'LightOpenID.php';
             $openid = new LightOpenID();
             if (!$openid->mode) {
                 switch ($provider) {
                     case 'google':
                         $openid->identity = 'https://www.google.com/accounts/o8/id';
                         $openid->required = array('namePerson/first', 'namePerson/last', 'contact/email');
                         header('Location: ' . $openid->authUrl());
                     default:
                         $this->_helper->flashMessenger('Provider not found');
                 }
             } elseif ($openid->mode == 'cancel') {
                 // Cancelled
             } else {
                 //                    if ($openid->validate()) {
                 $this->loginSuccessful($openid);
                 //                    } else {
                 // Logged Out
                 //                    }
             }
         } catch (Exception $e) {
             print $e->getMessage();
         }
     }
 }
開發者ID:hackjatra,項目名稱:atmlocator,代碼行數:30,代碼來源:UserController.php

示例8: 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

示例9: 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

示例10: validateOpenID

 /**
  * Try do OpenID validation (with the given redirect).
  * @return the validated LightOpenID object on success
  * @throws UserSignupException if anything bad happened
  */
 static function validateOpenID($openid, $redirect)
 {
     if (!is_valid_url($openid)) {
         throw new UserSignupException("That is not a valid OpenID identity.");
     }
     if (!$redirect) {
         throw new \InvalidArgumentException("No redirect provided.");
     }
     $light = new \LightOpenID(\Openclerk\Config::get("openid_host"));
     if (!$light->mode) {
         // we still need to authenticate
         $light->identity = $openid;
         $light->returnUrl = $redirect;
         redirect($light->authUrl());
         return false;
     } else {
         if ($light->mode == 'cancel') {
             // user has cancelled
             throw new UserSignupException("User has cancelled authentication.");
         } else {
             // otherwise login as necessary
             // optionally check for abuse etc
             if (!\Openclerk\Events::trigger('openid_validate', $light)) {
                 throw new UserSignupException("Login was cancelled by the system.");
             }
             if ($light->validate()) {
                 return $light;
             } else {
                 $error = $light->validate_error ? $light->validate_error : "Please try again.";
                 throw new UserSignupException("OpenID validation was not successful: " . $error);
             }
         }
     }
 }
開發者ID:openclerk,項目名稱:users,代碼行數:39,代碼來源:UserOpenID.php

示例11: 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

示例12: login

 /**
  * Log a user in. This function handles both stages of the process.
  * Firstly goes to google to get the users id,
  * Secondly gets the returned google id and saves it
  *
  * @return void
  * @author Nick Sheffield
  **/
 function login()
 {
     $openid = new LightOpenID();
     // if the process hasn't been started yet, go to google and start it
     if (!$openid->mode) {
         $openid->identity = 'https://www.google.com/accounts/o8/id';
         header('Location: ' . $openid->authUrl());
         echo $openid->authUrl();
         // if the process has been started already, save the resulting id
     } else {
         $openid->validate();
         $_SESSION['id'] = $openid->identity;
         header('Location: /unread');
         exit;
     }
 }
開發者ID:nicksheffield,項目名稱:OpenLater,代碼行數:24,代碼來源:user.php

示例13: 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

示例14: 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

示例15: requestID

 /**
 Launch OpenID request.
 */
 protected function requestID($url = null)
 {
     // openid form login
     $openid = new LightOpenID();
     $openid->identity = $url;
     $openid->required = array('contact/email', 'namePerson/friendly');
     //$openid->optional = array('namePerson/friendly');
     $this->redirect($openid->authUrl());
 }
開發者ID:sybreon,項目名稱:inorout,代碼行數:12,代碼來源:users_controller.php


注:本文中的LightOpenID::authUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。