Skip to content

Commit 3c4db4a

Browse files
committed
Remove auth set false
1 parent 40b9aae commit 3c4db4a

File tree

4 files changed

+30
-19
lines changed

4 files changed

+30
-19
lines changed

src/Database/Adapter/MariaDB.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,9 +1703,9 @@ public function find(
17031703
$alias = Query::DEFAULT_ALIAS;
17041704
$binds = [];
17051705

1706-
$collection = $context->getCollections()[0]->getId();
1706+
$name = $context->getCollections()[0]->getId();
1707+
$name = $this->filter($name);
17071708

1708-
$mainCollection = $this->filter($collection);
17091709
$roles = Authorization::getRoles();
17101710
$where = [];
17111711
$orders = [];
@@ -1811,14 +1811,14 @@ public function find(
18111811
$where[] = $conditions;
18121812
}
18131813

1814-
$skipAuth = $context->skipAuth($collection, $forPermission);
1814+
$skipAuth = $context->skipAuth($name, $forPermission);
18151815
if (! $skipAuth) {
1816-
$where[] = $this->getSQLPermissionsCondition($mainCollection, $roles, $alias, $forPermission);
1816+
$where[] = $this->getSQLPermissionsCondition($name, $roles, $alias, $forPermission);
18171817
}
18181818

18191819
if ($this->sharedTables) {
18201820
$binds[':_tenant'] = $this->tenant;
1821-
$where[] = "{$this->getTenantQuery($collection, $alias, condition: '')}";
1821+
$where[] = "{$this->getTenantQuery($name, $alias, condition: '')}";
18221822
}
18231823

18241824
$sqlWhere = !empty($where) ? 'WHERE ' . implode(' AND ', $where) : '';
@@ -1839,7 +1839,7 @@ public function find(
18391839

18401840
$sql = "
18411841
SELECT {$this->getAttributeProjectionV2($selects)}
1842-
FROM {$this->getSQLTable($mainCollection)} AS {$this->quote($alias)}
1842+
FROM {$this->getSQLTable($name)} AS {$this->quote($alias)}
18431843
{$sqlJoin}
18441844
{$sqlWhere}
18451845
{$sqlOrder}

src/Database/Database.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5705,6 +5705,10 @@ public function find(string $collection, array $queries = [], string $forPermiss
57055705
throw new AuthorizationException($authorization->getDescription());
57065706
}
57075707

5708+
var_dump('############');
5709+
var_dump($skipAuth);
5710+
var_dump($forPermission);
5711+
var_dump($_collection->getId());
57085712
$context->addSkipAuth($_collection->getId(), $forPermission, $skipAuth);
57095713
}
57105714

src/Database/QueryContext.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function add(Document $collection, string $alias = Query::DEFAULT_ALIAS):
6060

6161
public function addSkipAuth(string $collection, string $permission, bool $skipAuth): void
6262
{
63-
$this->skipAuthCollections[$permission][$collection] = $skipAuth;
63+
$this->skipAuthCollections[$collection][$permission] = $skipAuth;
6464

6565
var_dump($this->skipAuthCollections);
6666
}
@@ -71,9 +71,7 @@ public function skipAuth(string $collection, string $permission): bool
7171
return true;
7272
}
7373

74-
$this->skipAuthCollections[$permission][$collection] = false;
75-
76-
if (empty($this->skipAuthCollections[$permission][$collection])) {
74+
if (empty($this->skipAuthCollections[$collection][$permission])) {
7775
return false;
7876
}
7977

tests/e2e/Adapter/Base.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11344,7 +11344,8 @@ public function testSelectRelationshipAttributes(): void
1134411344

1134511345
// Select all parent attributes, some child attributes
1134611346
$make = static::getDatabase()->findOne('make', [
11347-
Query::select(['*', 'models.year']),
11347+
Query::select('*'),
11348+
Query::select('models.year')
1134811349
]);
1134911350

1135011351
if ($make->isEmpty()) {
@@ -11360,7 +11361,8 @@ public function testSelectRelationshipAttributes(): void
1136011361

1136111362
// Select all parent attributes, all child attributes
1136211363
$make = static::getDatabase()->findOne('make', [
11363-
Query::select(['*', 'models.*']),
11364+
Query::select('*'),
11365+
Query::select('models.*')
1136411366
]);
1136511367

1136611368
if ($make->isEmpty()) {
@@ -11377,7 +11379,7 @@ public function testSelectRelationshipAttributes(): void
1137711379
// Select all parent attributes, all child attributes
1137811380
// Must select parent if selecting children
1137911381
$make = static::getDatabase()->findOne('make', [
11380-
Query::select(['models.*']),
11382+
Query::select('models.*')
1138111383
]);
1138211384

1138311385
if ($make->isEmpty()) {
@@ -11393,7 +11395,7 @@ public function testSelectRelationshipAttributes(): void
1139311395

1139411396
// Select all parent attributes, no child attributes
1139511397
$make = static::getDatabase()->findOne('make', [
11396-
Query::select(['name']),
11398+
Query::select('name'),
1139711399
]);
1139811400

1139911401
if ($make->isEmpty()) {
@@ -11853,21 +11855,23 @@ public function testNestedOneToMany_OneToOneRelationship(): void
1185311855
$this->assertEquals('Mayor 1', $documents[0]['cities'][0]['mayor']['name']);
1185411856

1185511857
$documents = static::getDatabase()->find('countries', [
11856-
Query::select(['name']),
11858+
Query::select('name'),
1185711859
Query::limit(1)
1185811860
]);
1185911861
$this->assertArrayHasKey('name', $documents[0]);
1186011862
$this->assertArrayNotHasKey('cities', $documents[0]);
1186111863

1186211864
$documents = static::getDatabase()->find('countries', [
11863-
Query::select(['*']),
11865+
Query::select('*'),
1186411866
Query::limit(1)
1186511867
]);
1186611868
$this->assertArrayHasKey('name', $documents[0]);
1186711869
$this->assertArrayNotHasKey('cities', $documents[0]);
1186811870

1186911871
$documents = static::getDatabase()->find('countries', [
11870-
Query::select(['*', 'cities.*', 'cities.mayor.*']),
11872+
Query::select('*'),
11873+
Query::select('cities.*'),
11874+
Query::select('cities.mayor.*'),
1187111875
Query::limit(1)
1187211876
]);
1187311877

@@ -17183,12 +17187,17 @@ public function testDeleteBulkDocuments(): void
1718317187
/**
1718417188
* Test Short select query, test pagination as well, Add order to select
1718517189
*/
17186-
$selects = ['$internalId', '$id', '$collection', '$permissions', '$updatedAt'];
17190+
$selects = [];
17191+
$selects[] = Query::select('$internalId');
17192+
$selects[] = Query::select('$id');
17193+
$selects[] = Query::select('$collection');
17194+
$selects[] = Query::select('$permissions');
17195+
$selects[] = Query::select('$updatedAt');
1718717196

1718817197
$count = static::getDatabase()->deleteDocuments(
1718917198
collection: 'bulk_delete',
1719017199
queries: [
17191-
Query::select([...$selects, '$createdAt']),
17200+
[...$selects, Query::select('$createdAt')],
1719217201
Query::cursorAfter($docs[6]),
1719317202
Query::greaterThan('$createdAt', '2000-01-01'),
1719417203
Query::orderAsc('$createdAt'),

0 commit comments

Comments
 (0)