summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Controller/StoragesController.php
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-12-11 16:40:29 +0100
committerRobin Appelman <robin@icewind.nl>2021-01-08 15:06:42 +0100
commit518e91b0087058f2c9813da6a2427a56fc14e32c (patch)
treebd29f6831488b6393406efaa60886e2215f036bb /apps/files_external/lib/Controller/StoragesController.php
parent81302f78e5cea60dc9064be8ed979d523ff84e18 (diff)
downloadnextcloud-server-518e91b0087058f2c9813da6a2427a56fc14e32c.tar.gz
nextcloud-server-518e91b0087058f2c9813da6a2427a56fc14e32c.zip
dont offer to edit external config settings if we can't edit them
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external/lib/Controller/StoragesController.php')
-rw-r--r--apps/files_external/lib/Controller/StoragesController.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/apps/files_external/lib/Controller/StoragesController.php b/apps/files_external/lib/Controller/StoragesController.php
index 5d9ffedf885..d58d61e3939 100644
--- a/apps/files_external/lib/Controller/StoragesController.php
+++ b/apps/files_external/lib/Controller/StoragesController.php
@@ -40,9 +40,11 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\Files\StorageNotAvailableException;
+use OCP\IGroupManager;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
+use OCP\IUserSession;
/**
* Base class for storages controllers
@@ -69,6 +71,16 @@ abstract class StoragesController extends Controller {
protected $logger;
/**
+ * @var IUserSession
+ */
+ protected $userSession;
+
+ /**
+ * @var IGroupManager
+ */
+ protected $groupManager;
+
+ /**
* Creates a new storages controller.
*
* @param string $AppName application name
@@ -82,12 +94,16 @@ abstract class StoragesController extends Controller {
IRequest $request,
IL10N $l10n,
StoragesService $storagesService,
- ILogger $logger
+ ILogger $logger,
+ IUserSession $userSession,
+ IGroupManager $groupManager
) {
parent::__construct($AppName, $request);
$this->l10n = $l10n;
$this->service = $storagesService;
$this->logger = $logger;
+ $this->userSession = $userSession;
+ $this->groupManager = $groupManager;
}
/**
@@ -337,8 +353,12 @@ abstract class StoragesController extends Controller {
);
}
+ $data = $this->formatStorageForUI($storage)->jsonSerialize();
+ $isAdmin = $this->groupManager->isAdmin($this->userSession->getUser()->getUID());
+ $data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAl || $isAdmin;
+
return new DataResponse(
- $this->formatStorageForUI($storage),
+ $data,
Http::STATUS_OK
);
}