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


PHP TBGSettings::isOpenIDavailable方法代码示例

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


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

示例1: runDoLogin

 /**
  * Do login (AJAX call)
  *  
  * @param TBGRequest $request
  */
 public function runDoLogin(TBGRequest $request)
 {
     $i18n = TBGContext::getI18n();
     $options = $request->getParameters();
     $forward_url = TBGContext::getRouting()->generate('home');
     if ($request->hasParameter('persona') && $request['persona'] == 'true') {
         $url = 'https://verifier.login.persona.org/verify';
         $assert = filter_input(INPUT_POST, 'assertion', FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
         //Use the $_POST superglobal array for PHP < 5.2 and write your own filter
         $params = 'assertion=' . urlencode($assert) . '&audience=' . urlencode(TBGContext::getURLhost() . ':80');
         $ch = curl_init();
         $options = array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_POST => 2, CURLOPT_POSTFIELDS => $params);
         curl_setopt_array($ch, $options);
         $result = curl_exec($ch);
         curl_close($ch);
         $details = json_decode($result);
         $user = null;
         if ($details->status == 'okay') {
             $user = TBGUser::getByEmail($details->email);
             if ($user instanceof TBGUser) {
                 TBGContext::getResponse()->setCookie('tbg3_password', $user->getPassword());
                 TBGContext::getResponse()->setCookie('tbg3_username', $user->getUsername());
                 TBGContext::getResponse()->setCookie('tbg3_persona_session', true);
                 return $this->renderJSON(array('status' => 'login ok', 'redirect' => in_array($request['referrer_route'], array('home', 'login'))));
             }
         }
         if (!$user instanceof TBGUser) {
             $this->getResponse()->setHttpStatus(401);
             $this->renderJSON(array('message' => $this->getI18n()->__('Invalid login')));
         }
         return;
     }
     if (TBGSettings::isOpenIDavailable()) {
         $openid = new LightOpenID(TBGContext::getRouting()->generate('login_page', array(), false));
     }
     if (TBGSettings::isOpenIDavailable() && !$openid->mode && $request->isPost() && $request->hasParameter('openid_identifier')) {
         $openid->identity = $request->getRawParameter('openid_identifier');
         $openid->required = array('contact/email');
         $openid->optional = array('namePerson/first', 'namePerson/friendly');
         return $this->forward($openid->authUrl());
     } elseif (TBGSettings::isOpenIDavailable() && $openid->mode == 'cancel') {
         $this->error = TBGContext::getI18n()->__("OpenID authentication cancelled");
     } elseif (TBGSettings::isOpenIDavailable() && $openid->mode) {
         try {
             if ($openid->validate()) {
                 if ($this->getUser()->isAuthenticated() && !$this->getUser()->isGuest()) {
                     if (TBGOpenIdAccountsTable::getTable()->getUserIDfromIdentity($openid->identity)) {
                         TBGContext::setMessage('openid_used', true);
                         throw new Exception('OpenID already in use');
                     }
                     $user = $this->getUser();
                 } else {
                     $user = TBGUser::getByOpenID($openid->identity);
                 }
                 if ($user instanceof TBGUser) {
                     $attributes = $openid->getAttributes();
                     $email = array_key_exists('contact/email', $attributes) ? $attributes['contact/email'] : null;
                     if (!$user->getEmail()) {
                         if (array_key_exists('contact/email', $attributes)) {
                             $user->setEmail($attributes['contact/email']);
                         }
                         if (array_key_exists('namePerson/first', $attributes)) {
                             $user->setRealname($attributes['namePerson/first']);
                         }
                         if (array_key_exists('namePerson/friendly', $attributes)) {
                             $user->setBuddyname($attributes['namePerson/friendly']);
                         }
                         if (!$user->getNickname() || $user->isOpenIdLocked()) {
                             $user->setBuddyname($user->getEmail());
                         }
                         if (!$user->getRealname()) {
                             $user->setRealname($user->getBuddyname());
                         }
                         $user->save();
                     }
                     if (!$user->hasOpenIDIdentity($openid->identity)) {
                         TBGOpenIdAccountsTable::getTable()->addIdentity($openid->identity, $email, $user->getID());
                     }
                     TBGContext::getResponse()->setCookie('tbg3_password', $user->getPassword());
                     TBGContext::getResponse()->setCookie('tbg3_username', $user->getUsername());
                     if ($this->checkScopeMembership($user)) {
                         return true;
                     }
                     return $this->forward(TBGContext::getRouting()->generate(TBGSettings::get('returnfromlogin')));
                 } else {
                     $this->error = TBGContext::getI18n()->__("Didn't recognize this OpenID. Please log in using your username and password, associate it with your user account in your account settings and try again.");
                 }
             } else {
                 $this->error = TBGContext::getI18n()->__("Could not validate against the OpenID provider");
             }
         } catch (Exception $e) {
             $this->error = TBGContext::getI18n()->__("Could not validate against the OpenID provider: %message", array('%message' => htmlentities($e->getMessage(), ENT_COMPAT, TBGContext::getI18n()->getCharset())));
         }
     } elseif ($request->getMethod() == TBGRequest::POST) {
         try {
//.........这里部分代码省略.........
开发者ID:oparoz,项目名称:thebuggenie,代码行数:101,代码来源:actions.class.php

示例2: __

    if (TBGSettings::isOpenIDavailable()) {
        ?>
				<a class="persona-button orange" id="openid-signin-button" href="javascript:void(0);" onclick="$('regular_login_container').toggleClassName('active');$('openid_container').toggleClassName('active');"><span><?php 
        echo __('Sign in with OpenID');
        ?>
</span></a>
			<?php 
    }
    ?>
		</div>
	<?php 
}
?>
</div>
<?php 
if (TBGSettings::isOpenIDavailable()) {
    ?>
	<?php 
    include_component('main/openidbuttons');
}
TBGEvent::createNew('core', 'login_form_pane')->trigger(array_merge(array('selected_tab' => $selected_tab), $options));
if (TBGSettings::isRegistrationAllowed()) {
    ?>
	<div style="text-align: center;" id="registration-button-container" class="logindiv login_button_container registration_button_container active">
		<fieldset style="border: 0; border-top: 1px dotted rgba(0, 0, 0, 0.3); padding: 5px 100px; width: 100px; margin: 5px auto 0 auto;">
			<legend style="text-align: center; width: 100%; background-color: transparent;"><?php 
    echo __('%login or %signup', array('%login' => '', '%signup' => ''));
    ?>
</legend>
		</fieldset>
		<a href="javascript:void(0);" id="create-account-button" onclick="$('register').addClassName('active');$('registration-button-container').removeClassName('active');$('regular_login_container').removeClassName('active');$('openid_container').removeClassName('active');" class="button button-green"><?php 
开发者ID:oparoz,项目名称:thebuggenie,代码行数:31,代码来源:_login.inc.php


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