diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 4d8783f4dd..51988b027f 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -2068,11 +2068,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen } if ($documentSecurity && !$valid) { - try { - $document = $dbForProject->getDocument('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $documentId); - } catch (AuthorizationException) { - throw new Exception(Exception::USER_UNAUTHORIZED); - } + $document = $dbForProject->getDocument('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $documentId); } else { $document = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $documentId)); } diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index cdd1739b7d..0a524d3e13 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -746,11 +746,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId') } if ($fileSecurity && !$valid) { - try { - $file = $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId); - } catch (AuthorizationException) { - throw new Exception(Exception::USER_UNAUTHORIZED); - } + $file = $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId); } else { $file = Authorization::skip(fn() => $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId)); } @@ -829,11 +825,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') $key = \md5($fileId . $width . $height . $gravity . $quality . $borderWidth . $borderColor . $borderRadius . $opacity . $rotation . $background . $output); if ($fileSecurity && !$valid) { - try { - $file = $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId); - } catch (AuthorizationException) { - throw new Exception(Exception::USER_UNAUTHORIZED); - } + $file = $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId); } else { $file = Authorization::skip(fn() => $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId)); } @@ -967,11 +959,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/download') } if ($fileSecurity && !$valid) { - try { - $file = $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId); - } catch (AuthorizationException) { - throw new Exception(Exception::USER_UNAUTHORIZED); - } + $file = $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId); } else { $file = Authorization::skip(fn() => $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId)); } @@ -1102,11 +1090,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/view') } if ($fileSecurity && !$valid) { - try { - $file = $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId); - } catch (AuthorizationException) { - throw new Exception(Exception::USER_UNAUTHORIZED); - } + $file = $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId); } else { $file = Authorization::skip(fn() => $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId)); } @@ -1377,11 +1361,7 @@ App::delete('/v1/storage/buckets/:bucketId/files/:fileId') // Don't need to check valid here because we already ensured validity if ($fileSecurity) { - try { - $deleted = $dbForProject->deleteDocument('bucket_' . $bucket->getInternalId(), $fileId); - } catch (AuthorizationException) { - throw new Exception(Exception::USER_UNAUTHORIZED); - } + $deleted = $dbForProject->deleteDocument('bucket_' . $bucket->getInternalId(), $fileId); } else { $deleted = Authorization::skip(fn() => $dbForProject->deleteDocument('bucket_' . $bucket->getInternalId(), $fileId)); }