From 6fc176d50899251d0dddc3c881c0b56e68c3247a Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Wed, 24 May 2023 17:58:40 +0530 Subject: [PATCH] chore: add admin mode assertion for create collection --- app/controllers/api/databases.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 6d6e01fb6c..28b9837a47 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -718,11 +718,12 @@ App::post('/v1/databases/:databaseId/collections') ->inject('response') ->inject('dbForProject') ->inject('events') + ->inject('mode') ->action(function (string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, Response $response, Database $dbForProject, Event $events) { $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); - if ($database->isEmpty() || (!$database->getAttribute('enabled'))) { + if ($database->isEmpty() || (!$database->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { throw new Exception(Exception::DATABASE_NOT_FOUND); }