summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-07-25 09:31:39 +0200
committerJulius Härtl <jus@bitgrid.net>2019-08-02 08:39:24 +0200
commit30c44e1d24eadddd0eb6b4bc090933e2ee4c95a9 (patch)
treebb56ae9c2c6f4f02df5c70154298b189a9d8ad2e /apps/files_external/lib
parent72aaf2e5fbf501eeb4cae0445cd1398edbbacf37 (diff)
downloadnextcloud-server-30c44e1d24eadddd0eb6b4bc090933e2ee4c95a9.tar.gz
nextcloud-server-30c44e1d24eadddd0eb6b4bc090933e2ee4c95a9.zip
Provide proper user context from initMountPoints
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r--apps/files_external/lib/Config/ConfigAdapter.php2
-rw-r--r--apps/files_external/lib/Config/UserContext.php8
-rw-r--r--apps/files_external/lib/config.php10
3 files changed, 16 insertions, 4 deletions
diff --git a/apps/files_external/lib/Config/ConfigAdapter.php b/apps/files_external/lib/Config/ConfigAdapter.php
index 8d9c7ea8d1b..c9586635baf 100644
--- a/apps/files_external/lib/Config/ConfigAdapter.php
+++ b/apps/files_external/lib/Config/ConfigAdapter.php
@@ -76,7 +76,7 @@ class ConfigAdapter implements IMountProvider {
*/
private function prepareStorageConfig(StorageConfig &$storage, IUser $user) {
foreach ($storage->getBackendOptions() as $option => $value) {
- $storage->setBackendOption($option, \OC_Mount_Config::substitutePlaceholdersInConfig($value));
+ $storage->setBackendOption($option, \OC_Mount_Config::substitutePlaceholdersInConfig($value, $user->getUID()));
}
$objectStore = $storage->getBackendOption('objectstore');
diff --git a/apps/files_external/lib/Config/UserContext.php b/apps/files_external/lib/Config/UserContext.php
index 8fdca68f9b4..bec762358f2 100644
--- a/apps/files_external/lib/Config/UserContext.php
+++ b/apps/files_external/lib/Config/UserContext.php
@@ -39,6 +39,8 @@ class UserContext {
/** @var IRequest */
private $request;
+ private $user;
+
public function __construct(IUserSession $session, ShareManager $manager, IRequest $request) {
$this->session = $session;
$this->shareManager = $manager;
@@ -49,8 +51,14 @@ class UserContext {
return $this->session;
}
+ public function setUser($user): void {
+ $this->user = $user;
+ }
protected function getUserId(): ?string {
+ if ($this->user !== null) {
+ return $this->user;
+ }
if($this->session && $this->session->getUser() !== null) {
return $this->session->getUser()->getUID();
}
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index cc417a837fa..75ed59418d0 100644
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -50,6 +50,7 @@ use OCA\Files_External\Service\UserGlobalStoragesService;
use OCP\IUserManager;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
+use OCA\Files_External\Config\UserContext;
/**
* Class to configure mount.json globally and for users
@@ -107,7 +108,7 @@ class OC_Mount_Config {
$mountPoint = '/'.$uid.'/files'.$storage->getMountPoint();
$mountEntry = self::prepareMountPointEntry($storage, false);
foreach ($mountEntry['options'] as &$option) {
- $option = self::substitutePlaceholdersInConfig($option);
+ $option = self::substitutePlaceholdersInConfig($option, $uid);
}
$mountPoints[$mountPoint] = $mountEntry;
}
@@ -116,7 +117,7 @@ class OC_Mount_Config {
$mountPoint = '/'.$uid.'/files'.$storage->getMountPoint();
$mountEntry = self::prepareMountPointEntry($storage, true);
foreach ($mountEntry['options'] as &$option) {
- $option = self::substitutePlaceholdersInConfig($uid, $option);
+ $option = self::substitutePlaceholdersInConfig($option, $uid);
}
$mountPoints[$mountPoint] = $mountEntry;
}
@@ -215,12 +216,15 @@ class OC_Mount_Config {
* @throws \OCP\AppFramework\QueryException
* @since 16.0.0
*/
- public static function substitutePlaceholdersInConfig($input) {
+ public static function substitutePlaceholdersInConfig($input, $user = null) {
/** @var BackendService $backendService */
$backendService = self::$app->getContainer()->query(BackendService::class);
/** @var IConfigHandler[] $handlers */
$handlers = $backendService->getConfigHandlers();
foreach ($handlers as $handler) {
+ if ($handler instanceof UserContext) {
+ $handler->setUser($user);
+ }
$input = $handler->handle($input);
}
return $input;