aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Controller/UserGlobalStoragesController.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/lib/Controller/UserGlobalStoragesController.php')
-rw-r--r--apps/files_external/lib/Controller/UserGlobalStoragesController.php54
1 files changed, 16 insertions, 38 deletions
diff --git a/apps/files_external/lib/Controller/UserGlobalStoragesController.php b/apps/files_external/lib/Controller/UserGlobalStoragesController.php
index ba15afb2bdf..88a9f936401 100644
--- a/apps/files_external/lib/Controller/UserGlobalStoragesController.php
+++ b/apps/files_external/lib/Controller/UserGlobalStoragesController.php
@@ -1,28 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Juan Pablo Villafáñez <jvillafanez@solidgear.es>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Controller;
@@ -35,6 +16,8 @@ use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\UserGlobalStoragesService;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Attribute\NoAdminRequired;
+use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\IConfig;
use OCP\IGroupManager;
@@ -66,7 +49,7 @@ class UserGlobalStoragesController extends StoragesController {
LoggerInterface $logger,
IUserSession $userSession,
IGroupManager $groupManager,
- IConfig $config
+ IConfig $config,
) {
parent::__construct(
$AppName,
@@ -84,9 +67,8 @@ class UserGlobalStoragesController extends StoragesController {
* Get all storage entries
*
* @return DataResponse
- *
- * @NoAdminRequired
*/
+ #[NoAdminRequired]
public function index() {
/** @var UserGlobalStoragesService */
$service = $this->service;
@@ -115,16 +97,14 @@ class UserGlobalStoragesController extends StoragesController {
* Get an external storage entry.
*
* @param int $id storage id
- * @param bool $testOnly whether to storage should only test the connection or do more things
* @return DataResponse
- *
- * @NoAdminRequired
*/
- public function show($id, $testOnly = true) {
+ #[NoAdminRequired]
+ public function show($id) {
try {
$storage = $this->service->getStorage($id);
- $this->updateStorageStatus($storage, $testOnly);
+ $this->updateStorageStatus($storage);
} catch (NotFoundException $e) {
return new DataResponse(
[
@@ -138,7 +118,7 @@ class UserGlobalStoragesController extends StoragesController {
$data = $storage->jsonSerialize(true);
$isAdmin = $this->groupManager->isAdmin($this->userSession->getUser()->getUID());
- $data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAl || $isAdmin;
+ $data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAL || $isAdmin;
return new DataResponse(
$data,
@@ -152,16 +132,14 @@ class UserGlobalStoragesController extends StoragesController {
*
* @param int $id storage id
* @param array $backendOptions backend-specific options
- * @param bool $testOnly whether to storage should only test the connection or do more things
*
* @return DataResponse
- *
- * @NoAdminRequired
*/
+ #[NoAdminRequired]
+ #[PasswordConfirmationRequired(strict: true)]
public function update(
$id,
$backendOptions,
- $testOnly = true
) {
try {
$storage = $this->service->getStorage($id);
@@ -172,7 +150,7 @@ class UserGlobalStoragesController extends StoragesController {
} else {
return new DataResponse(
[
- 'message' => $this->l10n->t('Storage with ID "%d" is not user editable', [$id])
+ 'message' => $this->l10n->t('Storage with ID "%d" is not editable by non-admins', [$id])
],
Http::STATUS_FORBIDDEN
);
@@ -186,7 +164,7 @@ class UserGlobalStoragesController extends StoragesController {
);
}
- $this->updateStorageStatus($storage, $testOnly);
+ $this->updateStorageStatus($storage);
$this->sanitizeStorage($storage);
return new DataResponse(