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


PHP Settings::isOpenIDavailable方法代码示例

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


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

示例1: __

</button>
                            <h4><?php 
    echo __('Application password: %password_name', array('%password_name' => $password->getName()));
    ?>
</h4>
                            <p><?php 
    echo __('Last used: %last_used_time, created at: %created_at_time', array('%last_used_time' => $password->getLastUsedAt() ? tbg_formatTime($password->getLastUsedAt(), 20) : __('never used'), '%created_at_time' => tbg_formatTime($password->getCreatedAt(), 20)));
    ?>
</p>
                        </li>
                    <?php 
}
?>
                </ul>
                <?php 
if (\thebuggenie\core\framework\Settings::isOpenIDavailable()) {
    ?>
                    <h3>
                        <?php 
    echo __('Linked OpenID accounts');
    ?>
                        <button class="button button-silver" onclick="TBG.Main.Helpers.Backdrop.show('<?php 
    echo make_url('get_partial_for_backdrop', array('key' => 'openid'));
    ?>
');"><?php 
    echo __('Link an OpenID account');
    ?>
</button>
                    </h3>
                    <p><?php 
    echo __("Via %openid you can log in to The Bug Genie by authenticating via Google, Wordpress and a lot of other websites. This means you don't have to register an account specifically for The Bug Genie, but authenticate with your existing Google, Wordpress, etc. user account instead. The Bug Genie will not receive or store your external usernames or passwords.", array('%openid' => link_tag('http://openid.net', 'OpenID')));
开发者ID:RTechSoft,项目名称:thebuggenie,代码行数:31,代码来源:myaccount.html.php

示例2: runDoLogin

 /**
  * Do login (AJAX call)
  *
  * @Route(name="login", url="/do/login")
  * @AnonymousRoute
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runDoLogin(framework\Request $request)
 {
     $i18n = framework\Context::getI18n();
     $options = $request->getParameters();
     $forward_url = framework\Context::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(framework\Context::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 = entities\User::getByEmail($details->email);
             if ($user instanceof entities\User) {
                 framework\Context::getResponse()->setCookie('tbg3_password', $user->getPassword());
                 framework\Context::getResponse()->setCookie('tbg3_username', $user->getUsername());
                 framework\Context::getResponse()->setCookie('tbg3_persona_session', true);
                 $user->setOnline();
                 $user->save();
                 return $this->renderJSON(array('status' => 'login ok', 'redirect' => in_array($request['referer_route'], array('home', 'login'))));
             }
         }
         if (!$user instanceof entities\User) {
             $this->getResponse()->setHttpStatus(401);
             $this->renderJSON(array('message' => $this->getI18n()->__('Invalid login')));
         }
         return;
     }
     if (framework\Settings::isOpenIDavailable()) {
         $openid = new \LightOpenID(framework\Context::getRouting()->generate('login_page', array(), false));
     }
     if (framework\Settings::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 (framework\Settings::isOpenIDavailable() && $openid->mode == 'cancel') {
         $this->error = framework\Context::getI18n()->__("OpenID authentication cancelled");
     } elseif (framework\Settings::isOpenIDavailable() && $openid->mode) {
         try {
             if ($openid->validate()) {
                 if ($this->getUser()->isAuthenticated() && !$this->getUser()->isGuest()) {
                     if (tables\OpenIdAccounts::getTable()->getUserIDfromIdentity($openid->identity)) {
                         framework\Context::setMessage('openid_used', true);
                         throw new \Exception('OpenID already in use');
                     }
                     $user = $this->getUser();
                 } else {
                     $user = entities\User::getByOpenID($openid->identity);
                 }
                 if ($user instanceof entities\User) {
                     $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)) {
                         tables\OpenIdAccounts::getTable()->addIdentity($openid->identity, $user->getID());
                     }
                     framework\Context::getResponse()->setCookie('tbg3_password', $user->getPassword());
                     framework\Context::getResponse()->setCookie('tbg3_username', $user->getUsername());
                     $user->setOnline();
                     $user->save();
                     if ($this->checkScopeMembership($user)) {
                         return true;
                     }
                     return $this->forward(framework\Context::getRouting()->generate(framework\Settings::get('returnfromlogin')));
                 } else {
                     $this->error = framework\Context::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 {
//.........这里部分代码省略.........
开发者ID:nrensen,项目名称:thebuggenie,代码行数:101,代码来源:Main.php


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