本文整理汇总了PHP中common_session_SessionManager::startSession方法的典型用法代码示例。如果您正苦于以下问题:PHP common_session_SessionManager::startSession方法的具体用法?PHP common_session_SessionManager::startSession怎么用?PHP common_session_SessionManager::startSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common_session_SessionManager
的用法示例。
在下文中一共展示了common_session_SessionManager::startSession方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: legacy
/**
* Run the controller
*
* @param common_http_Request $pRequest
* @throws \ActionEnforcingException
* @throws \Exception
* @throws \common_exception_Error
* @throws \common_ext_ExtensionException
*/
public function legacy(common_http_Request $pRequest)
{
$resolver = new Resolver($pRequest);
// load the responsible extension
$ext = common_ext_ExtensionsManager::singleton()->getExtensionById($resolver->getExtensionId());
\Context::getInstance()->setExtensionName($resolver->getExtensionId());
// load translations
$uiLang = \common_session_SessionManager::getSession()->getInterfaceLanguage();
\tao_helpers_I18n::init($ext, $uiLang);
//if the controller is a rest controller we try to authenticate the user
$controllerClass = $resolver->getControllerClass();
if (is_subclass_of($controllerClass, \tao_actions_RestController::class)) {
$authAdapter = new \tao_models_classes_HttpBasicAuthAdapter(common_http_Request::currentRequest());
try {
$user = $authAdapter->authenticate();
$session = new \common_session_RestSession($user);
\common_session_SessionManager::startSession($session);
} catch (\common_user_auth_AuthFailedException $e) {
$data['success'] = false;
$data['errorCode'] = '401';
$data['errorMsg'] = 'You are not authorized to access this functionality.';
$data['version'] = TAO_VERSION;
header('HTTP/1.0 401 Unauthorized');
header('WWW-Authenticate: Basic realm="' . GENERIS_INSTANCE_NAME . '"');
echo json_encode($data);
exit(0);
}
}
try {
$enforcer = new ActionEnforcer($resolver->getExtensionId(), $resolver->getControllerClass(), $resolver->getMethodName(), $pRequest->getParams());
$enforcer->execute();
} catch (InterruptedActionException $iE) {
// Nothing to do here.
}
}
示例2: loadModule
/**
* (non-PHPdoc)
* @see FrontController::loadModule()
*/
public function loadModule()
{
$resolver = new Resolver($this->getRequest());
// load the responsible extension
common_ext_ExtensionsManager::singleton()->getExtensionById($resolver->getExtensionId());
\Context::getInstance()->setExtensionName($resolver->getExtensionId());
//if the controller is a rest controller we try to authenticate the user
$controllerClass = $resolver->getControllerClass();
if (is_subclass_of($controllerClass, 'tao_actions_CommonRestModule')) {
$authAdapter = new \tao_models_classes_HttpBasicAuthAdapter(common_http_Request::currentRequest());
try {
$user = $authAdapter->authenticate();
$session = new \common_session_RestSession($user);
\common_session_SessionManager::startSession($session);
} catch (\common_user_auth_AuthFailedException $e) {
$class = new $controllerClass();
$class->requireLogin();
}
}
try {
$enforcer = new ActionEnforcer($resolver->getExtensionId(), $resolver->getControllerClass(), $resolver->getMethodName(), $this->getRequest()->getParams());
$enforcer->execute();
} catch (InterruptedActionException $iE) {
// Nothing to do here.
}
}
示例3: __construct
public function __construct()
{
parent::__construct();
$authAdapter = new tao_models_classes_HttpBasicAuthAdapter(common_http_Request::currentRequest());
try {
$user = $authAdapter->authenticate();
$session = new common_session_RestSession($user);
\common_session_SessionManager::startSession($session);
} catch (common_user_auth_AuthFailedException $e) {
$this->requireLogin();
}
/*
$this->headers = tao_helpers_Http::getHeaders();
$this->files = tao_helpers_Http::getFiles();
*/
if ($this->hasHeader("Accept")) {
try {
$this->responseEncoding = tao_helpers_Http::acceptHeader($this->acceptedMimeTypes, $this->getHeader("Accept"));
} catch (common_exception_ClientException $e) {
$this->returnFailure($e);
}
}
if ($this->hasHeader("Accept-Language")) {
try {
} catch (common_exception_ClientException $e) {
$this->returnFailure($e);
}
}
header('Content-Type: ' . $this->responseEncoding);
//check auth method requested
/**/
}
示例4: roles
/**
* Action dedicated to fake roles
*/
public function roles()
{
$currentSession = \common_session_SessionManager::getSession();
if ($currentSession instanceof \common_session_RestrictedSession) {
$this->setData('roles', $currentSession->getUserRoles());
$this->setView('userdebug/restore.tpl');
} else {
$myFormContainer = new UserDebugRoles();
$myForm = $myFormContainer->getForm();
if ($myForm->isSubmited() && $myForm->isValid()) {
$user = $this->userService->getCurrentUser();
$filter = $myForm->getValue('rolefilter');
$userUri = $myForm->getValue('user');
if ($userUri != \common_session_SessionManager::getSession()->getUserUri()) {
throw new \common_exception_Error('Security exception, user to be changed is not the current user');
}
$session = new \common_session_RestrictedSession(\common_session_SessionManager::getSession(), $myForm->getValue('rolefilter'));
\common_session_SessionManager::startSession($session);
$this->setData('roles', $currentSession->getUserRoles());
$this->setView('userdebug/restore.tpl');
} else {
$this->setData('formTitle', __("Restrict Roles"));
$this->setData('myForm', $myForm->render());
$this->setView('form.tpl', 'tao');
}
}
}
示例5: startLtiSession
/**
* start a session from the provided OAuth Request
*
* @param common_http_Request $request
* @throws common_user_auth_AuthFailedException
*/
public function startLtiSession(common_http_Request $request)
{
$adapter = new taoLti_models_classes_LtiAuthAdapter($request);
$user = $adapter->authenticate();
$session = new taoLti_models_classes_TaoLtiSession($user);
common_session_SessionManager::startSession($session);
}
示例6: login
/**
* action to perform authwith open_ID
*/
public function login()
{
try {
# Change 'localhost' to your domain name.
$openid = new LightOpenID('http://e-learning-22/');
$openid_identfier = "http://192.168.0.201:8080/Sayegh-OpenID-Provider/auth";
if (!$openid->mode) {
if (isset($openid_identfier)) {
$openid->identity = $openid_identfier;
# The following two lines request email, full name, and a nickname
# from the provider. Remove them if you don't need that data.
$openid->required = array('contact/email', 'namePerson');
$openid->optional = array("role");
header('Location: ' . $openid->authUrl());
die;
}
?>
WTF you should never reached here! XO
<?php
} elseif ($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
$res = $openid->getAttributes();
// [contact/email] => sara@syrianep.com [namePerson] => sara lakah
$user = new OpenIDUser(new \core_kernel_classes_Resource("http://sep.com/" . $res['contact/email']));
$session = new \common_session_DefaultSession($user);
\common_session_SessionManager::startSession($session);
$this->redirect(_url('entry', 'Main', "tao"));
// echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
// print_r($openid->getAttributes());
}
} catch (ErrorException $e) {
echo $e->getMessage();
}
}
示例7: initTest
/**
* shared methods for test initialization
*/
public static function initTest()
{
//connect the API
if (!self::$connected) {
\common_session_SessionManager::startSession(new \common_test_TestUserSession());
self::$connected = true;
}
}
示例8: _isAllowed
protected function _isAllowed()
{
$session = new taoUpdate_models_classes_Session();
common_session_SessionManager::startSession($session);
return true;
}
示例9: startSession
/**
* Short description of method startSession
*
* @access public
* @author Jerome Bogaerts, <jerome@taotesting.com>
* @param Resource user
* @return boolean
*/
public function startSession(common_user_User $user)
{
$session = new common_session_DefaultSession($user);
return \common_session_SessionManager::startSession($session);
}
示例10: setSession
/**
* Sets the current session
* @param common_session_Session $session
* @return boolean
*/
public function setSession(common_session_Session $session)
{
return common_session_SessionManager::startSession($session);
}
示例11: restoreOriginal
/**
* Revert back to the original Session
*/
public function restoreOriginal()
{
common_session_SessionManager::startSession($this->internalSession);
}