1
0
Fork 0
mirror of synced 2024-07-02 21:20:58 +12:00

chore: add admin mode assertion for create collection

This commit is contained in:
Bishwajeet Parhi 2023-05-24 17:58:40 +05:30
parent 4706e6580d
commit 6fc176d508

View file

@ -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);
}