Skip to content

Commit 980e577

Browse files
committed
Added dbAuth middleware
1 parent 324cc10 commit 980e577

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

api.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -5207,12 +5207,14 @@ class DbAuthMiddleware extends Middleware
52075207
{
52085208
private $reflection;
52095209
private $db;
5210+
private $ordering;
52105211

52115212
public function __construct(Router $router, Responder $responder, array $properties, ReflectionService $reflection, GenericDB $db)
52125213
{
52135214
parent::__construct($router, $responder, $properties);
52145215
$this->reflection = $reflection;
52155216
$this->db = $db;
5217+
$this->ordering = new OrderingInfo();
52165218
}
52175219

52185220
public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
@@ -5242,7 +5244,8 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
52425244
$columnNames = array_map('trim', explode(',', $returnedColumns));
52435245
$columnNames[] = $passwordColumnName;
52445246
}
5245-
$users = $this->db->selectAll($table, $columnNames, $condition, [], 0, 1);
5247+
$columnOrdering = $this->ordering->getDefaultColumnOrdering($table);
5248+
$users = $this->db->selectAll($table, $columnNames, $condition, $columnOrdering, 0, 1);
52465249
foreach ($users as $user) {
52475250
if (password_verify($password, $user[$passwordColumnName]) == 1) {
52485251
if (!headers_sent()) {
@@ -7051,6 +7054,7 @@ public function _list(string $tableName, array $params): ListDocument
70517054
class RelationJoiner
70527055
{
70537056
private $reflection;
7057+
private $ordering;
70547058
private $columns;
70557059

70567060
public function __construct(ReflectionService $reflection, ColumnIncluder $columns)
@@ -7134,7 +7138,7 @@ private function addJoinsForTables(ReflectedTable $t1, PathTree $joins, array &$
71347138
foreach ($joins->getKeys() as $t2Name) {
71357139

71367140
$t2 = $this->reflection->getTable($t2Name);
7137-
7141+
71387142
$belongsTo = count($t1->getFksTo($t2->getName())) > 0;
71397143
$hasMany = count($t2->getFksTo($t1->getName())) > 0;
71407144
if (!$belongsTo && !$hasMany) {
@@ -7152,11 +7156,11 @@ private function addJoinsForTables(ReflectedTable $t1, PathTree $joins, array &$
71527156
if ($belongsTo) {
71537157
$fkValues = $this->getFkEmptyValues($t1, $t2, $records);
71547158
$this->addFkRecords($t2, $fkValues, $params, $db, $newRecords);
7155-
}
7159+
}
71567160
if ($hasMany) {
71577161
$pkValues = $this->getPkEmptyValues($t1, $records);
71587162
$this->addPkRecords($t1, $t2, $pkValues, $params, $db, $newRecords);
7159-
}
7163+
}
71607164
if ($hasAndBelongsToMany) {
71617165
$habtmValues = $this->getHabtmEmptyValues($t1, $t2, $t3, $db, $records);
71627166
$this->addFkRecords($t2, $habtmValues->fkValues, $params, $db, $newRecords);
@@ -7167,11 +7171,11 @@ private function addJoinsForTables(ReflectedTable $t1, PathTree $joins, array &$
71677171
if ($fkValues != null) {
71687172
$this->fillFkValues($t2, $newRecords, $fkValues);
71697173
$this->setFkValues($t1, $t2, $records, $fkValues);
7170-
}
7174+
}
71717175
if ($pkValues != null) {
71727176
$this->fillPkValues($t1, $t2, $newRecords, $pkValues);
71737177
$this->setPkValues($t1, $t2, $records, $pkValues);
7174-
}
7178+
}
71757179
if ($habtmValues != null) {
71767180
$this->fillFkValues($t2, $newRecords, $habtmValues->fkValues);
71777181
$this->setHabtmValues($t1, $t2, $records, $habtmValues);

0 commit comments

Comments
 (0)