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


PHP Context::getCurrentCLIusername方法代码示例

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


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

示例1: do_execute

 public function do_execute()
 {
     $this->cliEcho('Authenticating with server: ');
     $this->cliEcho($this->getProvidedArgument('server_url'), 'white', 'bold');
     $this->cliEcho("\n");
     $path = THEBUGGENIE_CONFIG_PATH;
     try {
         file_put_contents($path . '.remote_server', $this->getProvidedArgument('server_url'));
     } catch (\Exception $e) {
         $path = getenv('HOME') . DS;
         file_put_contents($path . '.remote_server', $this->getProvidedArgument('server_url'));
     }
     $this->cliEcho('Authenticating as user: ');
     $username = $this->getProvidedArgument('username', \thebuggenie\core\framework\Context::getCurrentCLIusername());
     $this->cliEcho($username, 'white', 'bold');
     $this->cliEcho("\n");
     file_put_contents($path . '.remote_username', $username);
     $this->_current_remote_server = file_get_contents($path . '.remote_server');
     $this->cliEcho("\n");
     $this->cliEcho('You need to authenticate using an application-specific password.');
     $this->cliEcho("\n");
     $this->cliEcho("Create an application password from your account's 'Security' tab.");
     $this->cliEcho("\n");
     $this->cliEcho("Enter the application-specific password: ", 'white', 'bold');
     $password = $this->_getCliInput();
     $response = $this->getRemoteResponse($this->getRemoteURL('api_authenticate', array('username' => $username)), array('password' => $password));
     if (!is_object($response)) {
         throw new \Exception('An error occured when receiving authentication response from the server');
     }
     file_put_contents($path . '.remote_token', sha1($response->token));
     $this->cliEcho("Authentication successful!\n", 'white', 'bold');
 }
开发者ID:pkdevboxy,项目名称:thebuggenie,代码行数:32,代码来源:Authenticate.php

示例2: loginCheck


//.........这里部分代码省略.........
                         }
                         if (framework\Context::getRequest()->hasCookie('tbg3_username') && framework\Context::getRequest()->hasCookie('tbg3_password')) {
                             $user = $mod->verifyLogin($username, $password);
                         } else {
                             $user = $mod->doLogin($username, $password);
                         }
                         if (!$user instanceof User) {
                             // Invalid
                             framework\Context::logout();
                             throw new \Exception('No such login');
                             //framework\Context::getResponse()->headerRedirect(framework\Context::getRouting()->generate('login'));
                         }
                     } catch (\Exception $e) {
                         throw $e;
                     }
                 } elseif (framework\Settings::isUsingExternalAuthenticationBackend()) {
                     $external = true;
                     framework\Logging::log('Authenticating without credentials with backend: ' . framework\Settings::getAuthenticationBackend(), 'auth', framework\Logging::LEVEL_INFO);
                     try {
                         $mod = framework\Context::getModule(framework\Settings::getAuthenticationBackend());
                         if ($mod->getType() !== Module::MODULE_AUTH) {
                             framework\Logging::log('Auth module is not the right type', 'auth', framework\Logging::LEVEL_FATAL);
                         }
                         $user = $mod->doAutoLogin();
                         if ($user == false) {
                             // Invalid
                             framework\Context::logout();
                             throw new \Exception('No such login');
                             //framework\Context::getResponse()->headerRedirect(framework\Context::getRouting()->generate('login'));
                         } else {
                             if ($user == true) {
                                 $user = null;
                             }
                         }
                     } catch (\Exception $e) {
                         throw $e;
                     }
                 } elseif ($username !== null && $password !== null && !$user instanceof User) {
                     $external = false;
                     framework\Logging::log('Using internal authentication', 'auth', framework\Logging::LEVEL_INFO);
                     $user = self::getB2DBTable()->getByUsername($username);
                     if ($user instanceof User && !$user->hasPassword($password)) {
                         $user = null;
                     }
                     if (!$user instanceof User) {
                         framework\Context::logout();
                     }
                 }
                 break;
             case framework\Action::AUTHENTICATION_METHOD_DUMMY:
                 $user = self::getB2DBTable()->getByUserID(framework\Settings::getDefaultUserID());
                 break;
             case framework\Action::AUTHENTICATION_METHOD_CLI:
                 $user = self::getB2DBTable()->getByUsername(framework\Context::getCurrentCLIusername());
                 break;
             case framework\Action::AUTHENTICATION_METHOD_RSS_KEY:
                 $user = self::getB2DBTable()->getByRssKey($request['rsskey']);
                 break;
             case framework\Action::AUTHENTICATION_METHOD_APPLICATION_PASSWORD:
                 $user = self::getB2DBTable()->getByUsername($request['api_username']);
                 if (!$user->authenticateApplicationPassword($request['api_token'])) {
                     $user = null;
                 }
                 break;
         }
         if ($user === null && !framework\Settings::isLoginRequired()) {
             $user = self::getB2DBTable()->getByUserID(framework\Settings::getDefaultUserID());
         }
         if ($user instanceof User) {
             if (!$user->isActivated()) {
                 throw new \Exception('This account has not been activated yet');
             } elseif (!$user->isEnabled()) {
                 throw new \Exception('This account has been suspended');
             } elseif (!$user->isConfirmedMemberOfScope(framework\Context::getScope())) {
                 if (!framework\Settings::isRegistrationAllowed()) {
                     throw new \Exception('This account does not have access to this scope');
                 }
             }
             if ($external == false && $authentication_method == framework\Action::AUTHENTICATION_METHOD_CORE) {
                 $password = $user->getHashPassword();
                 if (!$request->hasCookie('tbg3_username') && !$user->isGuest()) {
                     if ($request->getParameter('tbg3_rememberme')) {
                         framework\Context::getResponse()->setCookie('tbg3_username', $user->getUsername());
                         framework\Context::getResponse()->setCookie('tbg3_password', $user->getPassword());
                     } else {
                         framework\Context::getResponse()->setSessionCookie('tbg3_username', $user->getUsername());
                         framework\Context::getResponse()->setSessionCookie('tbg3_password', $user->getPassword());
                     }
                 }
             }
         } elseif (framework\Settings::isLoginRequired()) {
             throw new \Exception('Login required');
         } else {
             throw new \Exception('No such login');
         }
     } catch (\Exception $e) {
         throw $e;
     }
     return $user;
 }
开发者ID:underblaze,项目名称:thebuggenie-4.1.0,代码行数:101,代码来源:User.php


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