本文整理汇总了PHP中OC_User::isLoggedIn方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_User::isLoggedIn方法的具体用法?PHP OC_User::isLoggedIn怎么用?PHP OC_User::isLoggedIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_User
的用法示例。
在下文中一共展示了OC_User::isLoggedIn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkLoggedIn
/**
* Check if the user is logged in, send json error msg if not
*/
public static function checkLoggedIn() {
if( !OC_User::isLoggedIn()) {
$l = OC_L10N::get('lib');
self::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
exit();
}
}
示例2: checkLoggedIn
/**
* Check if the user is logged in, send json error msg if not
* @deprecated Use annotation based ACLs from the AppFramework instead
*/
public static function checkLoggedIn()
{
if (!OC_User::isLoggedIn()) {
$l = \OC::$server->getL10N('lib');
self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error')));
exit;
}
}
示例3: checkLoggedIn
/**
* Check if the user is logged in, send json error msg if not
*/
public static function checkLoggedIn()
{
if (!OC_User::isLoggedIn()) {
$l = new OC_L10N('core');
self::error(array('data' => array('message' => $l->t('Authentication error'))));
exit;
}
}
示例4: checkLoggedIn
/**
* Check if the user is logged in, send json error msg if not
* @deprecated Use annotation based ACLs from the AppFramework instead
*/
public static function checkLoggedIn()
{
if (!OC_User::isLoggedIn()) {
$l = \OC::$server->getL10N('lib');
http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED);
self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error')));
exit;
}
}
示例5: authenticate
/**
* Override function here. We want to cache authentication cookies
* in the syncing client to avoid HTTP-401 roundtrips.
* If the sync client supplies the cookies, then OC_User::isLoggedIn()
* will return true and we can see this WebDAV request as already authenticated,
* even if there are no HTTP Basic Auth headers.
* In other case, just fallback to the parent implementation.
*
* @return bool
*/
public function authenticate(Sabre_DAV_Server $server, $realm)
{
if (OC_User::handleApacheAuth() || OC_User::isLoggedIn()) {
$user = OC_User::getUser();
OC_Util::setupFS($user);
$this->currentUser = $user;
return true;
}
return parent::authenticate($server, $realm);
}
示例6: getStorage
/**
* Returns the cache storage for the logged in user
* @return \OC\Files\View cache storage
*/
protected function getStorage()
{
if (isset($this->storage)) {
return $this->storage;
}
if (\OC_User::isLoggedIn()) {
\OC\Files\Filesystem::initMountPoints(\OC_User::getUser());
$this->storage = new \OC\Files\View('/' . \OC_User::getUser() . '/cache');
return $this->storage;
} else {
\OC_Log::write('core', 'Can\'t get cache storage, user not logged in', \OC_Log::ERROR);
throw new \OC\ForbiddenException('Can\\t get cache storage, user not logged in');
}
}
示例7: changekeypasscode
public static function changekeypasscode($newpasscode)
{
if (OC_User::isLoggedIn()) {
$username = OC_USER::getUser();
// read old key
$key = file_get_contents(OC_Config::getValue("datadirectory") . '/' . $username . '/encryption.key');
// decrypt key with old passcode
$key = OC_Crypt::decrypt($key, $_SESSION['user_password']);
// encrypt again with new passcode
$key = OC_Crypt::encrypt($key, $newpassword);
// store the new key
file_put_contents(OC_Config::getValue("datadirectory") . '/' . $username . '/encryption.key', $key);
$_SESSION['user_password'] = $newpasscode;
}
}
示例8: validateUserPass
/**
* Validates a username and password
*
* This method should return true or false depending on if login
* succeeded.
*
* @return bool
*/
protected function validateUserPass($username, $password)
{
if (OC_User::isLoggedIn()) {
OC_Util::setupFS($username);
return true;
} else {
OC_Util::setUpFS();
//login hooks may need early access to the filesystem
if (OC_User::login($username, $password)) {
OC_Util::setUpFS(OC_User::getUser());
return true;
} else {
return false;
}
}
}
示例9: getStorage
/**
* Returns the cache storage for the logged in user
*
* @return \OC\Files\View cache storage
* @throws \OC\ForbiddenException
* @throws \OC\User\NoUserException
*/
protected function getStorage() {
if (isset($this->storage)) {
return $this->storage;
}
if (\OC_User::isLoggedIn()) {
$rootView = new View();
$user = \OC::$server->getUserSession()->getUser();
Filesystem::initMountPoints($user->getUID());
if (!$rootView->file_exists('/' . $user->getUID() . '/cache')) {
$rootView->mkdir('/' . $user->getUID() . '/cache');
}
$this->storage = new View('/' . $user->getUID() . '/cache');
return $this->storage;
} else {
\OCP\Util::writeLog('core', 'Can\'t get cache storage, user not logged in', \OCP\Util::ERROR);
throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in');
}
}
示例10: getStorage
protected function getStorage()
{
if (isset($this->storage)) {
return $this->storage;
}
if (OC_User::isLoggedIn()) {
$subdir = 'cache';
$view = new OC_FilesystemView('/' . OC_User::getUser());
if (!$view->file_exists($subdir)) {
$view->mkdir($subdir);
}
$this->storage = new OC_FilesystemView('/' . OC_User::getUser() . '/' . $subdir);
return $this->storage;
} else {
OC_Log::write('core', 'Can\'t get cache storage, user not logged in', OC_Log::ERROR);
return false;
}
}
示例11: __construct
public function __construct(array $urlParams = array())
{
parent::__construct('gatekeeper', $urlParams);
$container = $this->getContainer();
// Hooks
$container->registerService('GateKeeperHooks', function ($c) {
return new \OCA\GateKeeper\Hooks\GateKeeperHooks($c->query('GateKeeperService'), $c->query('Logger'));
});
// Service
$container->registerService('GateKeeperService', function ($c) {
return new \OCA\GateKeeper\Service\GateKeeperService($c->query('ServerContainer')->getAppConfig()->getValue('gatekeeper', 'mode'), $c->query('ServerContainer')->getSession(), $c->query('AccessObjectMapper'), $c->query('GroupManager'), GKHelper::isRemote(), $c->query('ServerContainer')->getAppConfig()->getValue('gatekeeper', 'refresh_delay'));
});
// Mapper
$container->registerService('AccessObjectMapper', function ($c) {
return new \OCA\GateKeeper\Db\AccessObjectMapper($c->query('ServerContainer')->getDb());
});
// groupManager
$container->registerService('GroupManager', function ($c) {
return \OC_Group::getManager();
});
// - logger -
$container->registerService('Logger', function ($c) {
return $c->query('ServerContainer')->getLogger();
});
$container->registerService('Interceptor', function ($c) {
return new \OCA\GateKeeper\AppInfo\Interceptor($c->query('ServerContainer')->getUserSession(), \OC_User::isLoggedIn(), $c->query('GateKeeperService'), $c->query('L10N'), $c->query('DenyLogger'));
});
$container->registerService('L10N', function ($c) {
return $c->query('ServerContainer')->getL10N($c->query('AppName'));
});
$container->registerService('SettingsController', function ($c) {
return new \OCA\GateKeeper\Controller\SettingsController($c->query('Request'), $c->query('ServerContainer')->getAppConfig(), $c->query('AccessObjectMapper'), $c->query('GroupManager'));
});
$container->registerService('DenyLoggerFactory', function ($c) {
return new \OCA\GateKeeper\Lib\DenyLoggerFactory($c->query('ServerContainer')->getAppConfig());
});
$container->registerService('DenyLogger', function ($c) {
return $c->query('DenyLoggerFactory')->getInstance();
});
}
示例12: isLoggedIn
/**
* Check if the user is logged in
* @return boolean
*/
public static function isLoggedIn()
{
return \OC_User::isLoggedIn();
}
示例13: array_merge
$_POST['install'] = 'true';
$_POST = array_merge($_POST, $AUTOCONFIG);
unlink($autosetup_file);
}
OC_Util::addScript('setup');
require_once 'setup.php';
exit;
}
// Handle WebDAV
if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') {
header('location: ' . OC_Helper::linkToRemote('webdav'));
exit;
} elseif (!OC_User::isLoggedIn() && substr(OC::$REQUESTEDFILE, -3) == 'css') {
OC_App::loadApps();
OC::loadfile();
} elseif (OC_User::isLoggedIn()) {
OC_App::loadApps();
if (isset($_GET["logout"]) and $_GET["logout"]) {
OC_User::logout();
header("Location: " . OC::$WEBROOT . '/');
exit;
} else {
if (is_null(OC::$REQUESTEDFILE)) {
OC::loadapp();
} else {
OC::loadfile();
}
}
// For all others cases, we display the guest page :
} else {
OC_App::loadApps();
示例14: progress
<?php
// Init owncloud
global $eventSource;
if (!OC_User::isLoggedIn()) {
exit;
}
\OC::$server->getSession()->close();
// Get the params
$dir = isset($_REQUEST['dir']) ? '/' . trim($_REQUEST['dir'], '/\\') : '';
$filename = isset($_REQUEST['filename']) ? trim($_REQUEST['filename'], '/\\') : '';
$content = isset($_REQUEST['content']) ? $_REQUEST['content'] : '';
$source = isset($_REQUEST['source']) ? trim($_REQUEST['source'], '/\\') : '';
if ($source) {
$eventSource = \OC::$server->createEventSource();
} else {
OC_JSON::callCheck();
}
function progress($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max)
{
static $filesize = 0;
static $lastsize = 0;
global $eventSource;
switch ($notification_code) {
case STREAM_NOTIFY_FILE_SIZE_IS:
$filesize = $bytes_max;
break;
case STREAM_NOTIFY_PROGRESS:
if ($bytes_transferred > 0) {
if (!isset($filesize) || $filesize === 0) {
} else {
示例15: auth
/**
* @param \Sabre\DAV\Server $server
* @param $realm
* @return bool
*/
private function auth(\Sabre\DAV\Server $server, $realm)
{
if (OC_User::handleApacheAuth() || OC_User::isLoggedIn() && is_null(\OC::$server->getSession()->get(self::DAV_AUTHENTICATED))) {
$user = OC_User::getUser();
OC_Util::setupFS($user);
$this->currentUser = $user;
\OC::$server->getSession()->close();
return true;
}
return parent::authenticate($server, $realm);
}