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


PHP TBGSettings::isUsingExternalAuthenticationBackend方法代碼示例

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


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

示例1: isPersonaAvailable

 public static function isPersonaAvailable()
 {
     if (TBGSettings::isUsingExternalAuthenticationBackend()) {
         return false;
         // No openID when using external auth
     }
     return (bool) self::isPersonaEnabled();
 }
開發者ID:oparoz,項目名稱:thebuggenie,代碼行數:8,代碼來源:TBGSettings.class.php

示例2: loginCheck

 /**
  * Returns the logged in user, or default user if not logged in
  *
  * @param TBGRequest $request
  * @param TBGAction  $action
  *
  * @return TBGUser
  */
 public static function loginCheck(TBGRequest $request, TBGAction $action)
 {
     try {
         $authentication_method = $action->getAuthenticationMethodForAction(TBGContext::getRouting()->getCurrentRouteAction());
         $user = null;
         $external = false;
         switch ($authentication_method) {
             case TBGAction::AUTHENTICATION_METHOD_ELEVATED:
             case TBGAction::AUTHENTICATION_METHOD_CORE:
                 $username = $request['tbg3_username'];
                 $password = $request['tbg3_password'];
                 if ($authentication_method == TBGAction::AUTHENTICATION_METHOD_ELEVATED) {
                     $elevated_password = $request['tbg3_elevated_password'];
                 }
                 $raw = true;
                 // If no username and password specified, check if we have a session that exists already
                 if ($username === null && $password === null) {
                     if (TBGContext::getRequest()->hasCookie('tbg3_username') && TBGContext::getRequest()->hasCookie('tbg3_password')) {
                         $username = TBGContext::getRequest()->getCookie('tbg3_username');
                         $password = TBGContext::getRequest()->getCookie('tbg3_password');
                         $user = TBGUsersTable::getTable()->getByUsername($username);
                         if ($authentication_method == TBGAction::AUTHENTICATION_METHOD_ELEVATED) {
                             $elevated_password = TBGContext::getRequest()->getCookie('tbg3_elevated_password');
                             if ($user instanceof TBGUser && !$user->hasPasswordHash($password)) {
                                 $user = null;
                             } else {
                                 if ($user instanceof TBGUser && !$user->hasPasswordHash($elevated_password)) {
                                     TBGContext::setUser($user);
                                     TBGContext::getRouting()->setCurrentRouteName('elevated_login_page');
                                     throw new TBGElevatedLoginException('reenter');
                                 }
                             }
                         } else {
                             if ($user instanceof TBGUser && !$user->hasPasswordHash($password)) {
                                 $user = null;
                             }
                         }
                         $raw = false;
                         if (!$user instanceof TBGUser) {
                             TBGContext::logout();
                             throw new Exception('No such login');
                         }
                     }
                 }
                 // If we have authentication details, validate them
                 if (TBGSettings::isUsingExternalAuthenticationBackend() && $username !== null && $password !== null) {
                     $external = true;
                     TBGLogging::log('Authenticating with backend: ' . TBGSettings::getAuthenticationBackend(), 'auth', TBGLogging::LEVEL_INFO);
                     try {
                         $mod = TBGContext::getModule(TBGSettings::getAuthenticationBackend());
                         if ($mod->getType() !== TBGModule::MODULE_AUTH) {
                             TBGLogging::log('Auth module is not the right type', 'auth', TBGLogging::LEVEL_FATAL);
                         }
                         if (TBGContext::getRequest()->hasCookie('tbg3_username') && TBGContext::getRequest()->hasCookie('tbg3_password')) {
                             $user = $mod->verifyLogin($username, $password);
                         } else {
                             $user = $mod->doLogin($username, $password);
                         }
                         if (!$user instanceof TBGUser) {
                             // Invalid
                             TBGContext::logout();
                             throw new Exception('No such login');
                             //TBGContext::getResponse()->headerRedirect(TBGContext::getRouting()->generate('login'));
                         }
                     } catch (Exception $e) {
                         throw $e;
                     }
                 } elseif (TBGSettings::isUsingExternalAuthenticationBackend()) {
                     $external = true;
                     TBGLogging::log('Authenticating without credentials with backend: ' . TBGSettings::getAuthenticationBackend(), 'auth', TBGLogging::LEVEL_INFO);
                     try {
                         $mod = TBGContext::getModule(TBGSettings::getAuthenticationBackend());
                         if ($mod->getType() !== TBGModule::MODULE_AUTH) {
                             TBGLogging::log('Auth module is not the right type', 'auth', TBGLogging::LEVEL_FATAL);
                         }
                         $user = $mod->doAutoLogin();
                         if ($user == false) {
                             // Invalid
                             TBGContext::logout();
                             throw new Exception('No such login');
                             //TBGContext::getResponse()->headerRedirect(TBGContext::getRouting()->generate('login'));
                         }
                     } catch (Exception $e) {
                         throw $e;
                     }
                 } elseif ($username !== null && $password !== null && !$user instanceof TBGUser) {
                     $external = false;
                     TBGLogging::log('Using internal authentication', 'auth', TBGLogging::LEVEL_INFO);
                     $user = TBGUsersTable::getTable()->getByUsername($username);
                     if (!$user->hasPassword($password)) {
                         $user = null;
                     }
//.........這裏部分代碼省略.........
開發者ID:oparoz,項目名稱:thebuggenie,代碼行數:101,代碼來源:TBGUser.class.php

示例3: __

        ?>
_random"><?php 
        echo __("Generate random new password");
        ?>
</label>
							<?php 
    }
    ?>
						</td>
					</tr>
					<tr id="edit_user_<?php 
    echo $user->getID();
    ?>
_password_container" style="display: none;">
						<?php 
    if (TBGSettings::isUsingExternalAuthenticationBackend()) {
        ?>
							<td colspan="2">
							</td>
						<?php 
    } else {
        ?>
							<td style="vertical-align: top; padding-top: 4px; line-height: 20px;">
								<label for="new_password_<?php 
        echo $user->getID();
        ?>
_1"><?php 
        echo __('New password');
        ?>
</label><br>
								<label for="new_password_<?php 
開發者ID:oparoz,項目名稱:thebuggenie,代碼行數:31,代碼來源:_finduser_row_editable.inc.php

示例4: logout

 /**
  * Log out the current user (does not work when auth method is set to http)
  */
 public static function logout()
 {
     if (TBGSettings::isUsingExternalAuthenticationBackend()) {
         $mod = TBGContext::getModule(TBGSettings::getAuthenticationBackend());
         $mod->logout();
     }
     TBGEvent::createNew('core', 'pre_logout')->trigger();
     self::getResponse()->deleteCookie('tbg3_username');
     self::getResponse()->deleteCookie('tbg3_password');
     self::getResponse()->deleteCookie('tbg3_elevated_password');
     self::getResponse()->deleteCookie('tbg3_persona_session');
     self::getResponse()->deleteCookie('THEBUGGENIE');
     session_regenerate_id(true);
     TBGEvent::createNew('core', 'post_logout')->trigger();
 }
開發者ID:oparoz,項目名稱:thebuggenie,代碼行數:18,代碼來源:TBGContext.class.php


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