本文整理汇总了PHP中OC_User::getUserSession方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_User::getUserSession方法的具体用法?PHP OC_User::getUserSession怎么用?PHP OC_User::getUserSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_User
的用法示例。
在下文中一共展示了OC_User::getUserSession方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkSingleUserMode
public static function checkSingleUserMode($lockIfNoUserLoggedIn = false)
{
if (!\OC::$server->getSystemConfig()->getValue('singleuser', false)) {
return;
}
$user = OC_User::getUserSession()->getUser();
if ($user) {
$group = \OC::$server->getGroupManager()->get('admin');
if ($group->inGroup($user)) {
return;
}
} else {
if (!$lockIfNoUserLoggedIn) {
return;
}
}
// send http status 503
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 120');
// render error page
$template = new OC_Template('', 'singleuser.user', 'guest');
$template->printPage();
die;
}
示例2: login
/**
* Try to login a user
*
* @param string $loginname The login name of the user to log in
* @param string $password The password of the user
* @return boolean|null
*
* Log in a user and regenerate a new session - if the password is ok
*/
public static function login($loginname, $password)
{
$result = \OC_User::getUserSession()->login($loginname, $password);
if ($result) {
// Refresh the token
\OC::$server->getCsrfTokenManager()->refreshToken();
//we need to pass the user name, which may differ from login name
$user = \OC_User::getUserSession()->getUser()->getUID();
\OC_Util::setupFS($user);
//trigger creation of user home and /files folder
\OC::$server->getUserFolder($user);
}
return $result;
}
示例3: registerCacheHooks
/**
* register hooks for the cache
*/
public static function registerCacheHooks() {
if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) { //don't try to do this before we are properly setup
\OCP\BackgroundJob::registerJob('OC\Cache\FileGlobalGC');
// NOTE: This will be replaced to use OCP
$userSession = \OC_User::getUserSession();
$userSession->listen('postLogin', '\OC\Cache\File', 'loginListener');
}
}
示例4: tearDownAfterClass
public static function tearDownAfterClass()
{
\OC_User::deleteUser(\OC_User::getUserSession()->getUser()->getUID());
}