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


PHP Auth_OpenID_SRegResponse类代码示例

本文整理汇总了PHP中Auth_OpenID_SRegResponse的典型用法代码示例。如果您正苦于以下问题:PHP Auth_OpenID_SRegResponse类的具体用法?PHP Auth_OpenID_SRegResponse怎么用?PHP Auth_OpenID_SRegResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetSRegDataForRequest

 public function GetSRegDataForRequest(User $user)
 {
     require_once 'Auth/OpenID/SReg.php';
     // Other common SReg fields we could fill are:
     //   dob, country, language, timezone.
     $sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($this->request);
     return Auth_OpenID_SRegResponse::extractResponse($sreg_request, array('fullname' => $user->fullName(), 'nickname' => $user->displayName(), 'email' => $user->bestEmail(), 'gender' => $user->isFemale() ? 'F' : 'M'));
 }
开发者ID:Ekleog,项目名称:platal,代码行数:8,代码来源:openid.inc.php

示例2: check

 function check()
 {
     $this->config->load('openid');
     $request_to = site_url($this->config->item('openid_request_to'));
     $this->openid->set_request_to($request_to);
     $response = $this->openid->getResponse();
     switch ($response->status) {
         case Auth_OpenID_CANCEL:
             $data['msg'] = $this->lang->line('openid_cancel');
             break;
         case Auth_OpenID_FAILURE:
             $data['error'] = $this->_set_message('openid_failure', $response->message);
             break;
         case Auth_OpenID_SUCCESS:
             $openid = $response->getDisplayIdentifier();
             $esc_identity = htmlspecialchars($openid, ENT_QUOTES);
             $data['success'] = $this->_set_message('openid_success', array($esc_identity, $esc_identity), array('%s', '%t'));
             if ($response->endpoint->canonicalID) {
                 $data['success'] .= $this->_set_message('openid_canonical', $response->endpoint->canonicalID);
             }
             $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
             $sreg = $sreg_resp->contents();
             foreach ($sreg as $key => $value) {
                 $data['success'] .= $this->_set_message('openid_content', array($key, $value), array('%s', '%t'));
             }
             $pape_resp = Auth_OpenID_PAPE_Response::fromSuccessResponse($response);
             if ($pape_resp) {
                 if ($pape_resp->auth_policies) {
                     $data['success'] .= $this->lang->line('openid_pape_policies_affected');
                     foreach ($pape_resp->auth_policies as $uri) {
                         $data['success'] .= "<li><tt>{$uri}</tt></li>";
                     }
                     $data['success'] .= "</ul>";
                 } else {
                     $data['success'] .= $this->lang->line('openid_pape_not_affected');
                 }
                 if (isset($pape_resp->auth_age) && $pape_resp->auth_age) {
                     $data['success'] .= $this->_set_message('openid_auth_age', $pape_resp->auth_age);
                 }
                 if ($pape_resp->nist_auth_level) {
                     $data['success'] .= $this->_set_message('openid_nist_level', $pape_resp->nist_auth_level);
                 }
             } else {
                 $data['success'] .= $this->lang->line('openid_pape_noresponse');
             }
             break;
     }
     $data['pape_policy_uris'] = array(PAPE_AUTH_MULTI_FACTOR_PHYSICAL, PAPE_AUTH_MULTI_FACTOR, PAPE_AUTH_PHISHING_RESISTANT);
     //		echo "nickname: $nickname";
     //		echo "esc_identity: $esc_identity";
     $this->load->view('view_openid', $data);
 }
开发者ID:istrwei,项目名称:P2P-Tube,代码行数:52,代码来源:test.php

示例3: perform

 /**
  *  login_finish action implementation.
  *
  *  @access public
  *  @return string  forward name.
  */
 public function perform()
 {
     // if login do?
     $identity = $this->af->get('openid_identity');
     if ($this->af->get('janrain_nonce')) {
         require_once 'Auth/OpenID.php';
         require_once "Auth/OpenID/Consumer.php";
         require_once "Auth/OpenID/FileStore.php";
         require_once "Auth/OpenID/SReg.php";
         require_once "Auth/OpenID/PAPE.php";
         $store_path = $this->backend->getController()->getDirectory('tmp') . "/openid_filestore";
         $consumer = new Auth_OpenID_Consumer(new Auth_OpenID_FileStore($store_path));
         $response = $consumer->complete($this->config->get('url') . "login_finish");
         if ($response->status == Auth_OpenID_CANCEL) {
             // This means the authentication was cancelled.
             $this->ae->add(null, "認証がキャンセルされました.Pastitを利用するには認証してください.");
             return 'login';
         } else {
             if ($response->status == Auth_OpenID_FAILURE) {
                 // Authentication failed; display the error message.
                 $this->ae->add(null, "認証に失敗しました.(" . $response->message . ")");
                 return 'login';
             } else {
                 if ($response->status == Auth_OpenID_SUCCESS) {
                     $openid_success_url = $response->getDisplayIdentifier();
                     $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
                     $sreg = $sreg_resp->contents();
                     $nickname = isset($sreg['nickname']) ? $sreg['nickname'] : "";
                     $this->session->set("identity", $identity);
                     $this->session->set("openid_success_url", $openid_success_url);
                 }
             }
         }
     }
     $um = $this->backend->getManager('user');
     if ($user = $um->getUserByIdentity($identity)) {
         $this->session->set('user', $user);
         return array('redirect', '/');
     } else {
         if (!Ethna::isError($id = $um->create($identity, $nickname))) {
             $user = $um->getUser($id);
             $this->session->set('user', $user);
             return array('redirect', 'setting');
         } else {
             $this->ae->addObject('name', $id);
             return 'error500';
         }
     }
     return 'login';
 }
开发者ID:riaf,项目名称:pastit,代码行数:56,代码来源:Finish.php

示例4: openid_check

function openid_check($ci, $callback_url, &$data)
{
    if (!isset($data)) {
        $data = array();
    }
    $ci->lang->load('openid');
    $ci->config->load('openid');
    $ci->openid->set_request_to($callback_url);
    $response = $ci->openid->getResponse();
    switch ($response->status) {
        case Auth_OpenID_CANCEL:
            push_message($ci->lang->line('openid_cancel'), 'error', $ci);
            break;
        case Auth_OpenID_FAILURE:
            push_message(set_message('openid_failure', $response->message), 'error', $ci);
            break;
        case Auth_OpenID_SUCCESS:
            $openid = $response->getDisplayIdentifier();
            $esc_identity = htmlspecialchars($openid, ENT_QUOTES);
            $data['openid_identifier'] = $openid;
            $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
            $sreg = $sreg_resp->contents();
            $ax_resp = new Auth_OpenID_AX_FetchResponse();
            $ax = $ax_resp->fromSuccessResponse($response);
            if (isset($sreg['email'])) {
                $data['email'] = $sreg['email'];
            }
            if ($ax) {
                if (isset($ax->data['http://axschema.org/contact/email'])) {
                    $data['email'] = $ax->getSingle('http://axschema.org/contact/email');
                }
                if (isset($ax->data['http://axschema.org/namePerson/first'])) {
                    $first_name = $ax->getSingle('http://axschema.org/namePerson/first');
                } else {
                    $first_name = "Sample";
                }
                if (isset($ax->data['http://axschema.org/namePerson/last'])) {
                    $last_name = $ax->getSingle('http://axschema.org/namePerson/last');
                } else {
                    $last_name = "Avatar";
                }
                if ($first_name != null && $last_name != null) {
                    $data['username'] = "{$first_name} {$last_name}";
                }
            }
            return true;
    }
    return false;
}
开发者ID:QuillLittlefeather,项目名称:mgm-simiangrid,代码行数:49,代码来源:simian_openid_helper.php

示例5: addSregFields

function addSregFields(&$response, $info, $req_url)
{
    $username = getUsernameFromUrl($req_url);
    $user = get_user_by_username($username);
    if ($user) {
        $email = $user->email;
        $fullname = $user->name;
        $sreg_data = array('fullname' => $fullname, 'email' => $email);
        // Add the simple registration response values to the OpenID
        // response message.
        $sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($info);
        $sreg_response = Auth_OpenID_SRegResponse::extractResponse($sreg_request, $sreg_data);
        //error_log('DEBUG:' . (string)($response->fields));
        $sreg_response->toMessage($response->fields);
    }
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:16,代码来源:common.php

示例6: doAuth

function doAuth($info, $trusted = null, $fail_cancels = false, $idpSelect = null)
{
    if (!$info) {
        // There is no authentication information, so bail
        return authCancel(null);
    }
    if ($info->idSelect()) {
        if ($idpSelect) {
            $req_url = idURL($idpSelect);
        } else {
            $trusted = false;
        }
    } else {
        $req_url = $info->identity;
    }
    $user = getLoggedInUser();
    setRequestInfo($info);
    if (!$info->idSelect() && $req_url != idURL($user)) {
        return login_render(array(), $req_url, $req_url);
    }
    $trust_root = $info->trust_root;
    if ($trusted) {
        setRequestInfo();
        $server =& getServer();
        $response =& $info->answer(true, null, $req_url);
        // Answer with some sample Simple Registration data.
        $sreg_data = array('fullname' => 'Example User', 'nickname' => 'example', 'dob' => '1970-01-01', 'email' => 'invalid@example.com', 'gender' => 'F', 'postcode' => '12345', 'country' => 'ES', 'language' => 'eu', 'timezone' => 'America/New_York');
        // Add the simple registration response values to the OpenID
        // response message.
        $sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($info);
        $sreg_response = Auth_OpenID_SRegResponse::extractResponse($sreg_request, $sreg_data);
        $sreg_response->toMessage($response->fields);
        // Generate a response to send to the user agent.
        $webresponse =& $server->encodeResponse($response);
        $new_headers = array();
        foreach ($webresponse->headers as $k => $v) {
            $new_headers[] = $k . ": " . $v;
        }
        return array($new_headers, $webresponse->body);
    } elseif ($fail_cancels) {
        return authCancel($info);
    } else {
        return trust_render($info);
    }
}
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:45,代码来源:common.php

示例7: run

function run()
{
    $consumer = getConsumer();
    // Complete the authentication process using the server's
    // response.
    $return_to = getReturnTo();
    $response = $consumer->complete($return_to);
    // Check the response status.
    if ($response->status == Auth_OpenID_CANCEL) {
        // This means the authentication was cancelled.
        $msg = '验证被取消。';
        //showmessage('cancel_openid_auth');
    } else {
        if ($response->status == Auth_OpenID_FAILURE) {
            // Authentication failed; display the error message.
            $msg = "OpenID 认证失败: " . $response->message;
        } else {
            if ($response->status == Auth_OpenID_SUCCESS) {
                // This means the authentication succeeded; extract the
                // identity URL and Simple Registration data (if it was
                // returned).
                // 将openid记录到session里,在session超时时间内,由以后的逻辑绑定到已注册的uid上。
                $_SESSION['openid_identifier'] = $response->getDisplayIdentifier();
                $_SESSION['openid_binding'] = time();
                //标记可以绑定了,但在发现是可直接登录用户时在要unset
                if ($response->endpoint->canonicalID) {
                    $_SESSION['xri_canonicalid'] = $response->endpoint->canonicalID;
                }
                $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
                $_SESSION['openid_sreg'] = $sreg_resp->contents();
                //NOTE:记录SREG到会话
                // echo var_dump($_SESSION['openid_identifier'])."--_SESSION['openid_identifier']<br>";
                // echo var_dump($_SESSION['openid_binding'])."--_SESSION['openid_binding']<br>";
                _OpenID_Action();
                //添加动作
            }
        }
    }
    displayError($msg);
}
开发者ID:AlexChien,项目名称:ey_uhome,代码行数:40,代码来源:finish_auth.php

示例8: fetchData

 /**
  * 
  * @return bool 
  * @param string $a_username
  * @param string $a_password
  * @param bool $isChallengeResponse[optional]
  */
 public function fetchData($a_username, $a_password, $isChallengeResponse = false)
 {
     global $ilLog;
     $ilLog->write(__METHOD__ . ': Fetch Data called');
     $response = $this->settings->getConsumer()->complete($this->settings->getReturnLocation());
     switch ($response->status) {
         case Auth_OpenID_CANCEL:
             die("Auth cancelled");
         case Auth_OpenID_FAILURE:
             die("Auth failed with message: " . $response->message);
         case Auth_OpenID_SUCCESS:
             $openid = $response->getDisplayIdentifier();
             $esc_identity = htmlentities($openid);
             $ilLog->write(__METHOD__ . ': Auth success with identity ' . $esc_identity);
             if ($response->endpoint->canonicalID) {
                 $escaped_canonicalID = htmlentities($response->endpoint->canonicalID);
                 $ilLog->write(__METHOD__ . ': Auth success with canonical id: ' . $esc_identity);
             }
             include_once 'Auth/OpenID/SReg.php';
             // Check if simple registration is supported
             if (Auth_OpenID_supportsSReg($response->endpoint)) {
                 $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response, true);
                 $this->response_data = $sreg_resp->contents();
                 $ilLog->write(__METHOD__ . ' auth data: ' . print_r($this->response_data, true));
                 return true;
             } else {
                 // Try to fetch response values
                 foreach ($response->message->args->keys as $key => $mapping) {
                     if ($mapping[1] == 'sreg.nickname') {
                         $this->response_data['nickname'] = $response->message->args->values[$key];
                     }
                     if ($mapping[1] == 'sreg.email') {
                         $this->response_data['email'] = $response->message->args->values[$key];
                     }
                 }
             }
             return true;
     }
     return false;
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:47,代码来源:class.ilAuthContainerOpenId.php

示例9: fromSuccessResponse

 /**
  * Create a C{L{SRegResponse}} object from a successful OpenID
  * library response
  * (C{L{openid.consumer.consumer.SuccessResponse}}) response
  * message
  *
  * success_response: A SuccessResponse from consumer.complete()
  *
  * signed_only: Whether to process only data that was
  * signed in the id_res message from the server.
  *
  * Returns a simple registration response containing the data that
  * was supplied with the C{id_res} response.
  */
 function fromSuccessResponse(&$success_response, $signed_only = true)
 {
     global $Auth_OpenID_sreg_data_fields;
     $obj = new Auth_OpenID_SRegResponse();
     $obj->ns_uri = $obj->_getSRegNS($success_response->message);
     if ($signed_only) {
         $args = $success_response->getSignedNS($obj->ns_uri);
     } else {
         $args = $success_response->message->getArgs($obj->ns_uri);
     }
     if ($args === null || Auth_OpenID::isFailure($args)) {
         return null;
     }
     foreach ($Auth_OpenID_sreg_data_fields as $field_name => $desc) {
         if (in_array($field_name, array_keys($args))) {
             $obj->data[$field_name] = $args[$field_name];
         }
     }
     return $obj;
 }
开发者ID:RangerWalt,项目名称:ecci,代码行数:34,代码来源:SReg.php

示例10: openid_server_sreg_auth_response

/**
 * Attach SReg response to authentication response.
 */
function openid_server_sreg_auth_response($response)
{
    $user = wp_get_current_user();
    // should we include SREG in the response?
    $include_sreg = false;
    if (isset($GLOBALS['openid_server_sreg_trust'])) {
        $include_sreg = $GLOBALS['openid_server_sreg_trust'];
    } else {
        $trusted_sites = get_usermeta($user->ID, 'openid_trusted_sites');
        $request = $response->request;
        $site_hash = md5($request->trust_root);
        if (is_array($trusted_sites) && array_key_exists($site_hash, $trusted_sites)) {
            $include_sreg = $trusted_sites[$site_hash]['release_attributes'];
        }
    }
    if ($include_sreg) {
        $sreg_data = array();
        foreach ($GLOBALS['Auth_OpenID_sreg_data_fields'] as $field => $name) {
            $sreg_data[$field] = openid_server_sreg_from_profile($field);
        }
        $sreg_response = Auth_OpenID_SRegResponse::extractResponse($GLOBALS['openid_server_sreg_request'], $sreg_data);
        $response->addExtension($sreg_response);
    }
    return $response;
}
开发者ID:alx,项目名称:pressid,代码行数:28,代码来源:server_ext.php

示例11: tryLogin

 /**
  * Try to log in using OpenID
  *
  * Check the OpenID for validity; potentially store it.
  *
  * @return void
  */
 function tryLogin()
 {
     $consumer = oid_consumer();
     $response = $consumer->complete(common_local_url('finishaddopenid'));
     if ($response->status == Auth_OpenID_CANCEL) {
         $this->message(_m('OpenID authentication cancelled.'));
         return;
     } else {
         if ($response->status == Auth_OpenID_FAILURE) {
             // Authentication failed; display the error message.
             $this->message(sprintf(_m('OpenID authentication failed: %s'), $response->message));
         } else {
             if ($response->status == Auth_OpenID_SUCCESS) {
                 $display = $response->getDisplayIdentifier();
                 $canonical = $response->endpoint && $response->endpoint->canonicalID ? $response->endpoint->canonicalID : $display;
                 $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
                 if ($sreg_resp) {
                     $sreg = $sreg_resp->contents();
                 }
                 $cur = common_current_user();
                 $other = oid_get_user($canonical);
                 if ($other) {
                     if ($other->id == $cur->id) {
                         $this->message(_m('You already have this OpenID!'));
                     } else {
                         $this->message(_m('Someone else already has this OpenID.'));
                     }
                     return;
                 }
                 // start a transaction
                 $cur->query('BEGIN');
                 $result = oid_link_user($cur->id, $canonical, $display);
                 if (!$result) {
                     $this->message(_m('Error connecting user.'));
                     return;
                 }
                 if ($sreg) {
                     if (!oid_update_user($cur, $sreg)) {
                         $this->message(_m('Error updating profile'));
                         return;
                     }
                 }
                 // success!
                 $cur->query('COMMIT');
                 oid_set_last($display);
                 common_redirect(common_local_url('openidsettings'), 303);
             }
         }
     }
 }
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:57,代码来源:finishaddopenid.php

示例12: postAuth

 /**
  * Process an authentication response.
  *
  * @param array &$state  The state array.
  */
 public function postAuth(array &$state)
 {
     $consumer = $this->getConsumer($state);
     $return_to = SimpleSAML_Utilities::selfURL();
     // Complete the authentication process using the server's
     // response.
     $response = $consumer->complete($return_to);
     // Check the response status.
     if ($response->status == Auth_OpenID_CANCEL) {
         // This means the authentication was cancelled.
         throw new SimpleSAML_Error_UserAborted();
     } else {
         if ($response->status == Auth_OpenID_FAILURE) {
             // Authentication failed; display the error message.
             throw new SimpleSAML_Error_AuthSource($this->authId, 'Authentication failed: ' . var_export($response->message, TRUE));
         } else {
             if ($response->status != Auth_OpenID_SUCCESS) {
                 throw new SimpleSAML_Error_AuthSource($this->authId, 'General error. Try again.');
             }
         }
     }
     // This means the authentication succeeded; extract the
     // identity URL and Simple Registration data (if it was
     // returned).
     $openid = $response->identity_url;
     $attributes = array('openid' => array($openid));
     $attributes['openid.server_url'] = array($response->endpoint->server_url);
     if ($response->endpoint->canonicalID) {
         $attributes['openid.canonicalID'] = array($response->endpoint->canonicalID);
     }
     if ($response->endpoint->local_id) {
         $attributes['openid.local_id'] = array($response->endpoint->local_id);
     }
     $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response, $this->validateSReg);
     $sregresponse = $sreg_resp->contents();
     if (is_array($sregresponse) && count($sregresponse) > 0) {
         $attributes['openid.sregkeys'] = array_keys($sregresponse);
         foreach ($sregresponse as $sregkey => $sregvalue) {
             $attributes['openid.sreg.' . $sregkey] = array($sregvalue);
         }
     }
     // Get AX response information
     $ax = new Auth_OpenID_AX_FetchResponse();
     $ax_resp = $ax->fromSuccessResponse($response);
     if ($ax_resp instanceof Auth_OpenID_AX_FetchResponse && !empty($ax_resp->data)) {
         $axresponse = $ax_resp->data;
         $attributes['openid.axkeys'] = array_keys($axresponse);
         foreach ($axresponse as $axkey => $axvalue) {
             if (preg_match("/^\\w+:/", $axkey)) {
                 $attributes[$axkey] = is_array($axvalue) ? $axvalue : array($axvalue);
             } else {
                 SimpleSAML_Logger::warning('Invalid attribute name in AX response: ' . var_export($axkey, TRUE));
             }
         }
     }
     SimpleSAML_Logger::debug('OpenID Returned Attributes: ' . implode(", ", array_keys($attributes)));
     $state['Attributes'] = $attributes;
     SimpleSAML_Auth_Source::completeAuth($state);
 }
开发者ID:danielkjfrog,项目名称:docker,代码行数:64,代码来源:OpenIDConsumer.php

示例13: openid_get_user_data_sreg

/**
 * Retrieve user data from OpenID Simple Registration.
 *
 * @param string $identity_url OpenID to get user data about
 * @param reference $data reference to user data array
 * @see get_user_data
 */
function openid_get_user_data_sreg($data, $identity_url)
{
    require_once dirname(__FILE__) . '/Auth/OpenID/SReg.php';
    $response = openid_response();
    $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
    $sreg = $sreg_resp->contents();
    if (!$sreg) {
        return $data;
    }
    if (array_key_exists('email', $sreg) && $sreg['email']) {
        $data['user_email'] = $sreg['email'];
    }
    if (array_key_exists('nickname', $sreg) && $sreg['nickname']) {
        $data['nickname'] = $sreg['nickname'];
        $data['user_nicename'] = $sreg['nickname'];
        $data['display_name'] = $sreg['nickname'];
    }
    if (array_key_exists('fullname', $sreg) && $sreg['fullname']) {
        $namechunks = explode(' ', $sreg['fullname'], 2);
        if (isset($namechunks[0])) {
            $data['first_name'] = $namechunks[0];
        }
        if (isset($namechunks[1])) {
            $data['last_name'] = $namechunks[1];
        }
        $data['display_name'] = $sreg['fullname'];
    }
    return $data;
}
开发者ID:alx,项目名称:pressid,代码行数:36,代码来源:common.php

示例14: finishAuth

 function finishAuth($tid)
 {
     // Complete the authentication process using the server's response.
     $tr = Transaction::taste($tid);
     ob_start();
     $response = $this->consumer->complete($tr['finishURL']);
     ob_end_clean();
     $msg = '';
     if ($response->status == Auth_OpenID_CANCEL) {
         // This means the authentication was cancelled.
         $msg = _text("인증이 취소되었습니다.");
     } else {
         if ($response->status == Auth_OpenID_FAILURE) {
             $msg = _text("오픈아이디 인증이 실패하였습니다: ") . $response->message;
         } else {
             if ($response->status == Auth_OpenID_SUCCESS) {
                 $this->openid = $response->identity_url;
                 $this->delegatedid = $response->endpoint->local_id;
                 $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
                 $this->sreg = $sreg_resp->contents();
                 if (!isset($this->sreg['nickname'])) {
                     $this->sreg['nickname'] = "";
                 }
                 $msg = '';
                 if (empty($tr['authenticate_only'])) {
                     $this->setAcl($this->openid);
                     $this->update($this->openid, $this->delegatedid, $this->sreg['nickname']);
                     if (!empty($tr['need_writers'])) {
                         if (!Acl::check('group.writers')) {
                             $msg = _text("관리자 권한이 없는 오픈아이디 입니다") . " : " . $this->openid;
                         }
                     }
                     fireEvent("AfterOpenIDLogin", $this->openid);
                 } else {
                     Acl::authorize('openid_temp', $this->openid);
                 }
             }
         }
     }
     return $msg ? $this->_redirectWithError($msg, $tid) : $this->_redirectWithSucess($tid);
 }
开发者ID:Avantians,项目名称:Textcube,代码行数:41,代码来源:Textcube.Control.Openid.php

示例15: onAuthenticate


//.........这里部分代码省略.........
         $session->set('trust_url', $trust_url);
         // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
         // form to send a POST request to the server.
         if ($auth_request->shouldSendRedirect()) {
             $redirect_url = $auth_request->redirectURL($trust_url, $process_url);
             // If the redirect URL can't be built, display an error
             // message.
             if (Auth_OpenID::isFailure($redirect_url)) {
                 displayError("Could not redirect to server: " . $redirect_url->message);
             } else {
                 // Send redirect.
                 $mainframe->redirect($redirect_url);
                 return false;
             }
         } else {
             // Generate form markup and render it.
             $form_id = 'openid_message';
             $form_html = $auth_request->htmlMarkup($trust_url, $process_url, false, array('id' => $form_id));
             // Display an error if the form markup couldn't be generated;
             // otherwise, render the HTML.
             if (Auth_OpenID::isFailure($form_html)) {
                 //displayError("Could not redirect to server: " . $form_html->message);
             } else {
                 JResponse::setBody($form_html);
                 echo JResponse::toString($mainframe->getCfg('gzip'));
                 $mainframe->close();
                 return false;
             }
         }
     }
     $result = $consumer->complete($session->get('return_url'));
     switch ($result->status) {
         case Auth_OpenID_SUCCESS:
             $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($result);
             $sreg = $sreg_resp->contents();
             $usermode = $this->params->get('usermode', 2);
             /* in the following code, we deal with the transition from the old openid version to the new openid version
                In the old version, the username was always taken straight from the login form.  In the new version, we get a
                username back from the openid provider.  This is necessary for a number of reasons.  First, providers such as
                yahoo.com allow you to enter only the provider name in the username field (i.e. yahoo.com or flickr.com).  Taking
                this as the username would obviously cause problems because everybody who had an id from yahoo.com would have username
                yahoo.com.  Second, it is necessary because with the old way, we rely on the user entering the id the same every time.
                This is bad because if the user enters the http:// one time and not the second time, they end up as two different users.
                There are two possible settings here - the first setting, is to always use the new way, which is to get the username from
                the provider after authentication.  The second setting is to check if the username exists that we got from the provider.  If it
                doesn't, then we check if the entered username exists.  If it does, then we update the database with the username from the provider
                and continue happily along with the new username.
                We had talked about a third option, which would be to always used the old way, but that seems insecure in the case of somebody using
                a yahoo.com ID.
             */
             if ($usermode && $usermode == 1) {
                 $response->username = $result->getDisplayIdentifier();
             } else {
                 // first, check if the provider provided username exists in the database
                 $db =& JFactory::getDBO();
                 $query = 'SELECT username FROM #__users' . ' WHERE username=' . $db->Quote($result->getDisplayIdentifier()) . ' AND password=\'\'';
                 $db->setQuery($query);
                 $dbresult = $db->loadObject();
                 if ($dbresult) {
                     // if so, we set our username value to the provided value
                     $response->username = $result->getDisplayIdentifier();
                 } else {
                     // if it doesn't, we check if the username from the from exists in the database
                     $query = 'SELECT username FROM #__users' . ' WHERE username=' . $db->Quote($credentials['username']) . ' AND password=\'\'';
                     $db->setQuery($query);
                     $dbresult = $db->loadObject();
开发者ID:kwizera05,项目名称:police,代码行数:67,代码来源:openid.php


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