diff options
3 files changed, 50 insertions, 7 deletions
diff --git a/apps/files_external/controller/storagescontroller.php b/apps/files_external/controller/storagescontroller.php index 07e2e69f601..64b989f0c77 100644 --- a/apps/files_external/controller/storagescontroller.php +++ b/apps/files_external/controller/storagescontroller.php @@ -212,6 +212,15 @@ abstract class StoragesController extends Controller { return null; } + protected function manipulateStorageConfig(StorageConfig $storage) { + /** @var AuthMechanism */ + $authMechanism = $storage->getAuthMechanism(); + $authMechanism->manipulateStorageConfig($storage); + /** @var Backend */ + $backend = $storage->getBackend(); + $backend->manipulateStorageConfig($storage); + } + /** * Check whether the given storage is available / valid. * @@ -222,13 +231,10 @@ abstract class StoragesController extends Controller { */ protected function updateStorageStatus(StorageConfig &$storage) { try { - /** @var AuthMechanism */ - $authMechanism = $storage->getAuthMechanism(); - $authMechanism->manipulateStorageConfig($storage); + $this->manipulateStorageConfig($storage); + /** @var Backend */ $backend = $storage->getBackend(); - $backend->manipulateStorageConfig($storage); - // update status (can be time-consuming) $storage->setStatus( \OC_Mount_Config::getBackendStatus( diff --git a/apps/files_external/controller/userglobalstoragescontroller.php b/apps/files_external/controller/userglobalstoragescontroller.php index 5aea7875ed4..85e843a4235 100644 --- a/apps/files_external/controller/userglobalstoragescontroller.php +++ b/apps/files_external/controller/userglobalstoragescontroller.php @@ -21,6 +21,7 @@ namespace OCA\Files_External\Controller; +use OCA\Files_External\Lib\Auth\AuthMechanism; use \OCP\IRequest; use \OCP\IL10N; use \OCP\AppFramework\Http\DataResponse; @@ -30,24 +31,32 @@ use \OCA\Files_external\Service\UserGlobalStoragesService; use \OCA\Files_external\NotFoundException; use \OCA\Files_external\Lib\StorageConfig; use \OCA\Files_External\Lib\Backend\Backend; +use OCP\IUserSession; /** * User global storages controller */ class UserGlobalStoragesController extends StoragesController { /** + * @var IUserSession + */ + private $userSession; + + /** * Creates a new user global storages controller. * * @param string $AppName application name * @param IRequest $request request object * @param IL10N $l10n l10n service * @param UserGlobalStoragesService $userGlobalStoragesService storage service + * @param IUserSession $userSession */ public function __construct( $AppName, IRequest $request, IL10N $l10n, - UserGlobalStoragesService $userGlobalStoragesService + UserGlobalStoragesService $userGlobalStoragesService, + IUserSession $userSession ) { parent::__construct( $AppName, @@ -55,6 +64,7 @@ class UserGlobalStoragesController extends StoragesController { $l10n, $userGlobalStoragesService ); + $this->userSession = $userSession; } /** @@ -78,12 +88,22 @@ class UserGlobalStoragesController extends StoragesController { ); } + protected function manipulateStorageConfig(StorageConfig $storage) { + /** @var AuthMechanism */ + $authMechanism = $storage->getAuthMechanism(); + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); + /** @var Backend */ + $backend = $storage->getBackend(); + $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); + } + /** * Get an external storage entry. * * @param int $id storage id * @return DataResponse * + * @NoCSRFRequired * @NoAdminRequired */ public function show($id) { diff --git a/apps/files_external/controller/userstoragescontroller.php b/apps/files_external/controller/userstoragescontroller.php index 345e4bf652b..afc30de456b 100644 --- a/apps/files_external/controller/userstoragescontroller.php +++ b/apps/files_external/controller/userstoragescontroller.php @@ -23,6 +23,7 @@ namespace OCA\Files_External\Controller; +use OCA\Files_External\Lib\Auth\AuthMechanism; use \OCP\IConfig; use \OCP\IUserSession; use \OCP\IRequest; @@ -41,6 +42,11 @@ use \OCA\Files_External\Lib\Backend\Backend; */ class UserStoragesController extends StoragesController { /** + * @var IUserSession + */ + private $userSession; + + /** * Creates a new user storages controller. * * @param string $AppName application name @@ -52,7 +58,8 @@ class UserStoragesController extends StoragesController { $AppName, IRequest $request, IL10N $l10n, - UserStoragesService $userStoragesService + UserStoragesService $userStoragesService, + IUserSession $userSession ) { parent::__construct( $AppName, @@ -60,6 +67,16 @@ class UserStoragesController extends StoragesController { $l10n, $userStoragesService ); + $this->userSession = $userSession; + } + + protected function manipulateStorageConfig(StorageConfig $storage) { + /** @var AuthMechanism */ + $authMechanism = $storage->getAuthMechanism(); + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); + /** @var Backend */ + $backend = $storage->getBackend(); + $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); } /** |