Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking for local external storage flag iff the method is local. #27621

Merged
merged 4 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 28 additions & 30 deletions apps/files_external/lib/Controller/GlobalStoragesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,42 +89,40 @@ public function create(
) {
$canCreateNewLocalStorage = \OC::$server->getConfig()->getSystemValue('files_external_allow_create_new_local', false);

if ($canCreateNewLocalStorage === true) {
$newStorage = $this->createStorage(
$mountPoint,
$backend,
$authMechanism,
$backendOptions,
$mountOptions,
$applicableUsers,
$applicableGroups,
$priority
if ($backend === 'local' && $canCreateNewLocalStorage === false) {
return new DataResponse(
null,
Http::STATUS_FORBIDDEN
);
if ($newStorage instanceof DataResponse) {
return $newStorage;
}
}

$response = $this->validate($newStorage);
if (!empty($response)) {
return $response;
}
$newStorage = $this->createStorage(
$mountPoint,
$backend,
$authMechanism,
$backendOptions,
$mountOptions,
$applicableUsers,
$applicableGroups,
$priority
);
if ($newStorage instanceof DataResponse) {
return $newStorage;
}

$newStorage = $this->service->addStorage($newStorage);
$response = $this->validate($newStorage);
if (!empty($response)) {
return $response;
}

$this->updateStorageStatus($newStorage);
$newStorage = $this->service->addStorage($newStorage);

return new DataResponse(
$newStorage,
Http::STATUS_CREATED
);
}
$this->updateStorageStatus($newStorage);

else {
return new DataResponse(
null,
Http::STATUS_FORBIDDEN
);
}
return new DataResponse(
$newStorage,
Http::STATUS_CREATED
);
}

/**
Expand Down
52 changes: 25 additions & 27 deletions apps/files_external/lib/Controller/UserStoragesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,38 +128,36 @@ public function create(
) {
$canCreateNewLocalStorage = \OC::$server->getConfig()->getSystemValue('files_external_allow_create_new_local', false);

if ($canCreateNewLocalStorage === true) {
$newStorage = $this->createStorage(
$mountPoint,
$backend,
$authMechanism,
$backendOptions,
$mountOptions
);
if ($newStorage instanceOf DataResponse) {
return $newStorage;
}

$response = $this->validate($newStorage);
if (!empty($response)) {
return $response;
}

$newStorage = $this->service->addStorage($newStorage);
$this->updateStorageStatus($newStorage);

return new DataResponse(
$newStorage,
Http::STATUS_CREATED
);
}

else {
if ($backend === 'local' && $canCreateNewLocalStorage === false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could remove this completely, users are never allowed to setup local storages for security reasons

return new DataResponse(
null,
Http::STATUS_FORBIDDEN
);
}

$newStorage = $this->createStorage(
$mountPoint,
$backend,
$authMechanism,
$backendOptions,
$mountOptions
);
if ($newStorage instanceOf DataResponse) {
return $newStorage;
}

$response = $this->validate($newStorage);
if (!empty($response)) {
return $response;
}

$newStorage = $this->service->addStorage($newStorage);
$this->updateStorageStatus($newStorage);

return new DataResponse(
$newStorage,
Http::STATUS_CREATED
);
}

/**
Expand Down