mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 01:18:37 +00:00
Merge pull request #8929 from appwrite/validate-string-permissions
Validate string permissions
This commit is contained in:
commit
d7c64b6557
1 changed files with 4 additions and 5 deletions
|
|
@ -816,22 +816,21 @@ App::post('/v1/databases/:databaseId/collections')
|
||||||
$collectionId = $collectionId == 'unique()' ? ID::unique() : $collectionId;
|
$collectionId = $collectionId == 'unique()' ? ID::unique() : $collectionId;
|
||||||
|
|
||||||
// Map aggregate permissions into the multiple permissions they represent.
|
// Map aggregate permissions into the multiple permissions they represent.
|
||||||
$permissions = Permission::aggregate($permissions);
|
$permissions = Permission::aggregate($permissions) ?? [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$dbForProject->createDocument('database_' . $database->getInternalId(), new Document([
|
$collection = $dbForProject->createDocument('database_' . $database->getInternalId(), new Document([
|
||||||
'$id' => $collectionId,
|
'$id' => $collectionId,
|
||||||
'databaseInternalId' => $database->getInternalId(),
|
'databaseInternalId' => $database->getInternalId(),
|
||||||
'databaseId' => $databaseId,
|
'databaseId' => $databaseId,
|
||||||
'$permissions' => $permissions ?? [],
|
'$permissions' => $permissions,
|
||||||
'documentSecurity' => $documentSecurity,
|
'documentSecurity' => $documentSecurity,
|
||||||
'enabled' => $enabled,
|
'enabled' => $enabled,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'search' => implode(' ', [$collectionId, $name]),
|
'search' => implode(' ', [$collectionId, $name]),
|
||||||
]));
|
]));
|
||||||
$collection = $dbForProject->getDocument('database_' . $database->getInternalId(), $collectionId);
|
|
||||||
|
|
||||||
$dbForProject->createCollection('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), permissions: $permissions ?? [], documentSecurity: $documentSecurity);
|
$dbForProject->createCollection('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), permissions: $permissions, documentSecurity: $documentSecurity);
|
||||||
} catch (DuplicateException) {
|
} catch (DuplicateException) {
|
||||||
throw new Exception(Exception::COLLECTION_ALREADY_EXISTS);
|
throw new Exception(Exception::COLLECTION_ALREADY_EXISTS);
|
||||||
} catch (LimitException) {
|
} catch (LimitException) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue