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


PHP LightOpenID::getAttributes方法代碼示例

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


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

示例1: getEmail

 /**
  * @return string
  */
 public function getEmail()
 {
     $atts = $this->_loid->getAttributes();
     if (isset($atts["contact/email"])) {
         return $atts["contact/email"];
     }
     return "";
 }
開發者ID:andi98,項目名稱:antragsgruen,代碼行數:11,代碼來源:AntragUserIdentityOAuth.php

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

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

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

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

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

示例7: receiveData

 /**
  * OpenID プロバイダから返卻されたパラメータを受け取ります。
  * 
  * @return bool パラメータを正しく解析できた場合に TRUE を返します。
  *   リクエストの妥當性をチェックする場合は {@link isAuthenticated()} メソッドを使用して下さい。
  * @author Naomichi Yamakita <yamakita@dtx.co.jp>
  */
 public function receiveData()
 {
     $this->_attributeExchange = new Mars_OpenIDAttributeExchange($this->_openId->getAttributes());
     // レスポンスは GET、または POST で返される
     $data = $this->request->getParameter('openid_mode');
     if (null_or_empty($data)) {
         return FALSE;
     }
     if ($this->request->getQuery('openid_mode') != 'cancel' && $this->_openId->validate()) {
         $this->_identity = $this->request->getParameter('openid_identity');
     }
     return TRUE;
 }
開發者ID:naomichi-y,項目名稱:mars_plugin,代碼行數:20,代碼來源:Mars_OpenID.class.php

示例8: request

 /**
  * Ask for OpenID identifer
  */
 public function request()
 {
     if (!$this->openid->mode) {
         $this->openid->identity = 'http://steamcommunity.com/openid';
         header('Location: ' . $this->openid->authUrl());
         exit;
     } else {
         if ($this->openid->mode == 'cancel') {
             $this->errorCallback(array('provider' => 'Steam', 'code' => 'cancel_authentication', 'message' => 'User has canceled authentication'));
         } else {
             if (!$this->openid->validate()) {
                 $this->errorCallback(array('provider' => 'Steam', 'code' => 'not_logged_in', 'message' => 'User has not logged in'));
             } else {
                 $steamId = '';
                 if (preg_match('/http:\\/\\/steamcommunity.com\\/openid\\/id\\/(\\d+)/', $this->openid->data['openid_identity'], $matches)) {
                     $steamId = $matches[1];
                 }
                 $userInfo = $this->userInfo($steamId);
                 $this->auth = array('provider' => 'Steam', 'uid' => $steamId, 'info' => $userInfo, 'credentials' => $this->openid->getAttributes(), 'raw' => $userInfo);
                 $this->callback();
             }
         }
     }
 }
開發者ID:rnewton,項目名稱:opauth_steam,代碼行數:27,代碼來源:SteamStrategy.php

示例9: authenticateOpenId

 protected function authenticateOpenId($openidIdentity)
 {
     // 3rd-party library: http://gitorious.org/lightopenid
     // Required: PHP 5, curl
     $openid = new LightOpenID();
     $openid->required = array('namePerson/friendly', 'contact/email');
     $openid->optional = array('namePerson/first');
     if (isset($_GET['openid_mode'])) {
         $result = $openid->validate();
         $this->_openidIdentity = $openid->identity;
         $this->_attributes = $openid->getAttributes();
         return $result;
     }
     $openid->identity = $openidIdentity;
     header('Location: ' . $openid->authUrl());
     exit;
 }
開發者ID:alexqwert,項目名稱:kanon,代碼行數:17,代碼來源:openidUserIdentity.php

示例10: add

 public function add(\LightOpenID $openId)
 {
     $attrs = $openId->getAttributes();
     $uzivatel = $this->get($openId->identity);
     $arr = array(self::COLUMN_IDENTITY => $openId->identity);
     if (!empty($attrs['namePerson'])) {
         $arr[self::COLUMN_NAME] = $attrs['namePerson'];
     }
     if (!empty($attrs['contact/email'])) {
         $arr[self::COLUMN_EMAIL] = $attrs['contact/email'];
     }
     if (empty($uzivatel)) {
         $this->database->query("INSERT INTO " . self::TABLE_NAME, $arr);
     } else {
         $this->database->query("UPDATE " . self::TABLE_NAME . " SET ", $arr, " WHERE " . self::COLUMN_IDENTITY . "=?;", $openId->identity);
     }
     $user = $this->get($openId->identity);
     return $user;
 }
開發者ID:stanley89,項目名稱:piratskelisty,代碼行數:19,代碼來源:Uzivatele.php

示例11: doOpenId

 protected function doOpenId($identity)
 {
     require "vendor/lightopenid/openid.php";
     $openid = new \LightOpenID(Ntentan::$config['application']['domain']);
     if (!$openid->mode) {
         $identity = $openid->discover($identity);
         $openid->identity = $identity;
         $openid->required = array('contact/email', 'namePerson/first', 'namePerson/last', 'namePerson/friendly');
         header('Location: ' . $openid->authUrl());
     } elseif ($openid->mode == 'cancel') {
         return "cancelled";
     } else {
         if ($openid->validate()) {
             $oidStatus = $openid->getAttributes();
             $status = array('email' => $oidStatus['contact/email'], 'firstname' => $oidStatus['namePerson/first'], 'lastname' => $oidStatus['namePerson/last'], 'nickname' => $oidStatus['namePerson/friendly'], 'key' => $oidStatus['contact/email']);
             return $status;
         } else {
             return "failed";
         }
     }
 }
開發者ID:ntentan,項目名稱:social-extension,代碼行數:21,代碼來源:AbstractSignin.php

示例12: _handleOpenIDResponse

 /**
  * Validates the OpenID provider's response and logs in the user.
  * 
  * If the user doesn't already exist, a new user account is created for them
  * and their attributes are saved.
  * 
  * @return void
  */
 public function _handleOpenIDResponse()
 {
     if ($this->LightOpenID->mode == 'cancel') {
         $this->Session->setFlash(__('Login canceled'), 'default', array(), 'auth');
     } else {
         if ($this->LightOpenID->validate()) {
             if (!$this->_existsOpenIDUser($this->LightOpenID->identity)) {
                 $this->_registerOpenIDUser($this->LightOpenID->identity, $this->LightOpenID->getAttributes());
             }
             $data = $this->_loadOpenIDUser($this->LightOpenID->identity);
             if ($data) {
                 $this->Auth->login($data['User']);
                 $this->redirect($this->Auth->redirect());
             } else {
                 $this->Session->setFlash("OpenID verified, but failed to load user data from the database");
             }
         } else {
             $this->Session->setFlash(__('OpenID verification failed'), 'default', array(), 'auth');
         }
     }
 }
開發者ID:sanyaade-machine-learning,項目名稱:Catool,代碼行數:29,代碼來源:OpenidAuthServiceComponent.php

示例13: LightOpenID

 function action_finishAuth()
 {
     $openid = new LightOpenID();
     if (!$openid->validate()) {
         $this->request->redirect('auth/login');
         return;
     }
     $this->session->regenerate();
     $this->session->set('account_id', $_GET['openid_identity']);
     $attr = $openid->getAttributes();
     if (@$attr['contact/email']) {
         $this->session->set('account_email', $attr['contact/email']);
     }
     if (@$attr['namePerson/first'] && @$attr['namePerson/last']) {
         $this->session->set('account_displayName', implode(' ', array(@$attr['namePerson/first'], @$attr['namePerson/last'])));
     } else {
         if (@$attr['namePerson']) {
             $this->session->set('account_displayName', $attr['namePerson']);
         } else {
             if (@$attr['namePerson/friendly']) {
                 $this->session->set('account_displayName', $attr['namePerson/friendly']);
             }
         }
     }
     if (!($this->session->get('account_email') && $this->session->get('account_displayName'))) {
         echo "<br/><pre><xmp>";
         var_dump($openid);
         var_dump($openid->getAttributes());
         echo "</xmp></pre>";
         die;
     }
     $location = $this->session->get('redirected_from');
     $this->session->delete('redirected_from');
     if (!$location) {
         $location = "admin/index";
     }
     $this->request->redirect($location);
 }
開發者ID:halkeye,項目名稱:tops,代碼行數:38,代碼來源:auth.php

示例14: get

 function get()
 {
     $noid = get_config('system', 'disable_openid');
     if ($noid) {
         goaway(z_root());
     }
     logger('mod_openid ' . print_r($_REQUEST, true), LOGGER_DATA);
     if (x($_REQUEST, 'openid_mode')) {
         $openid = new LightOpenID(z_root());
         if ($openid->validate()) {
             logger('openid: validate');
             $authid = normalise_openid($_REQUEST['openid_identity']);
             if (!strlen($authid)) {
                 logger(t('OpenID protocol error. No ID returned.') . EOL);
                 goaway(z_root());
             }
             $x = match_openid($authid);
             if ($x) {
                 $r = q("select * from channel where channel_id = %d limit 1", intval($x));
                 if ($r) {
                     $y = q("select * from account where account_id = %d limit 1", intval($r[0]['channel_account_id']));
                     if ($y) {
                         foreach ($y as $record) {
                             if ($record['account_flags'] == ACCOUNT_OK || $record['account_flags'] == ACCOUNT_UNVERIFIED) {
                                 logger('mod_openid: openid success for ' . $x[0]['channel_name']);
                                 $_SESSION['uid'] = $r[0]['channel_id'];
                                 $_SESSION['account_id'] = $r[0]['channel_account_id'];
                                 $_SESSION['authenticated'] = true;
                                 authenticate_success($record, $r[0], true, true, true, true);
                                 goaway(z_root());
                             }
                         }
                     }
                 }
             }
             // Successful OpenID login - but we can't match it to an existing account.
             // See if they've got an xchan
             $r = q("select * from xconfig left join xchan on xchan_hash = xconfig.xchan where cat = 'system' and k = 'openid' and v = '%s' limit 1", dbesc($authid));
             if ($r) {
                 $_SESSION['authenticated'] = 1;
                 $_SESSION['visitor_id'] = $r[0]['xchan_hash'];
                 $_SESSION['my_url'] = $r[0]['xchan_url'];
                 $_SESSION['my_address'] = $r[0]['xchan_addr'];
                 $arr = array('xchan' => $r[0], 'session' => $_SESSION);
                 call_hooks('magic_auth_openid_success', $arr);
                 \App::set_observer($r[0]);
                 require_once 'include/security.php';
                 \App::set_groups(init_groups_visitor($_SESSION['visitor_id']));
                 info(sprintf(t('Welcome %s. Remote authentication successful.'), $r[0]['xchan_name']));
                 logger('mod_openid: remote auth success from ' . $r[0]['xchan_addr']);
                 if ($_SESSION['return_url']) {
                     goaway($_SESSION['return_url']);
                 }
                 goaway(z_root());
             }
             // no xchan...
             // create one.
             // We should probably probe the openid url and figure out if they have any kind of
             // social presence we might be able to scrape some identifying info from.
             $name = $authid;
             $url = trim($_REQUEST['openid_identity'], '/');
             if (strpos($url, 'http') === false) {
                 $url = 'https://' . $url;
             }
             $pphoto = z_root() . '/' . get_default_profile_photo();
             $parsed = @parse_url($url);
             if ($parsed) {
                 $host = $parsed['host'];
             }
             $attr = $openid->getAttributes();
             if (is_array($attr) && count($attr)) {
                 foreach ($attr as $k => $v) {
                     if ($k === 'namePerson/friendly') {
                         $nick = notags(trim($v));
                     }
                     if ($k === 'namePerson/first') {
                         $first = notags(trim($v));
                     }
                     if ($k === 'namePerson') {
                         $name = notags(trim($v));
                     }
                     if ($k === 'contact/email') {
                         $addr = notags(trim($v));
                     }
                     if ($k === 'media/image/aspect11') {
                         $photosq = trim($v);
                     }
                     if ($k === 'media/image/default') {
                         $photo_other = trim($v);
                     }
                 }
             }
             if (!$nick) {
                 if ($first) {
                     $nick = $first;
                 } else {
                     $nick = $name;
                 }
             }
             require_once 'library/urlify/URLify.php';
//.........這裏部分代碼省略.........
開發者ID:phellmes,項目名稱:hubzilla-addons,代碼行數:101,代碼來源:Mod_Openid.php

示例15: elseif

 if (!empty($server) and in_array($server, $global_config['openid_servers'])) {
     if (file_exists(NV_ROOTDIR . '/modules/users/login/oauth-' . $server . '.php')) {
         include NV_ROOTDIR . '/modules/users/login/oauth-' . $server . '.php';
     } elseif (file_exists(NV_ROOTDIR . '/modules/users/login/cas-' . $server . '.php')) {
         include NV_ROOTDIR . '/modules/users/login/cas-' . $server . '.php';
     } else {
         include_once NV_ROOTDIR . '/includes/class/openid.class.php';
         $openid = new LightOpenID();
         if ($nv_Request->isset_request('openid_mode', 'get')) {
             $openid_mode = $nv_Request->get_string('openid_mode', 'get', '');
             if ($openid_mode == 'cancel') {
                 $attribs = array('result' => 'cancel');
             } elseif (!$openid->validate()) {
                 $attribs = array('result' => 'notlogin');
             } else {
                 $attribs = array('result' => 'is_res', 'id' => $openid->identity, 'server' => $server) + $openid->getAttributes();
             }
             $attribs = serialize($attribs);
             $nv_Request->set_Session('openid_attribs', $attribs);
             $op_redirect = defined('NV_IS_USER') ? 'openid' : 'login';
             Header('Location: ' . NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op_redirect . '&server=' . $server . '&result=1&nv_redirect=' . $nv_redirect);
             exit;
         }
         if (!$nv_Request->isset_request('result', 'get')) {
             include_once NV_ROOTDIR . '/modules/users/login/openid-' . $server . '.php';
             $openid->identity = $openid_server_config['identity'];
             $openid->required = array_values($openid_server_config['required']);
             header('Location: ' . $openid->authUrl());
             die;
         }
         exit;
開發者ID:lzhao18,項目名稱:nukeviet,代碼行數:31,代碼來源:oauth.php


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