Skip to content

Commit 92478e1

Browse files
committed
fix for #952
1 parent 57d6859 commit 92478e1

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

api.include.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8342,10 +8342,13 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
83428342
$username = isset($body->$usernameFormFieldName) ? $body->$usernameFormFieldName : '';
83438343
$password = isset($body->$passwordFormFieldName) ? $body->$passwordFormFieldName : '';
83448344
$newPassword = isset($body->$newPasswordFormFieldName) ? $body->$newPasswordFormFieldName : '';
8345-
if ($path === 'login')
8346-
$tableName = $this->getProperty('loginTable', 'users'); //add separate property for login as this could be a view joining users table to other table such as roles, details etc. At a minimum, the view output should include the $usernameColumn and $passwordColumn
8347-
else
8345+
//add separate property for login as this could be a view joining users table to other table
8346+
//such as roles, details etc. At a minimum, the view output should include the $usernameColumn and $passwordColumn
8347+
if ($path === 'login') {
8348+
$tableName = $this->getProperty('loginTable', $this->getProperty('usersTable', 'users'));
8349+
} else {
83488350
$tableName = $this->getProperty('usersTable', 'users');
8351+
}
83498352
$table = $this->reflection->getTable($tableName);
83508353
$usernameColumnName = $this->getProperty('usernameColumn', 'username');
83518354
$usernameColumn = $table->getColumn($usernameColumnName);

api.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8342,10 +8342,13 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
83428342
$username = isset($body->$usernameFormFieldName) ? $body->$usernameFormFieldName : '';
83438343
$password = isset($body->$passwordFormFieldName) ? $body->$passwordFormFieldName : '';
83448344
$newPassword = isset($body->$newPasswordFormFieldName) ? $body->$newPasswordFormFieldName : '';
8345-
if ($path === 'login')
8346-
$tableName = $this->getProperty('loginTable', 'users'); //add separate property for login as this could be a view joining users table to other table such as roles, details etc. At a minimum, the view output should include the $usernameColumn and $passwordColumn
8347-
else
8345+
//add separate property for login as this could be a view joining users table to other table
8346+
//such as roles, details etc. At a minimum, the view output should include the $usernameColumn and $passwordColumn
8347+
if ($path === 'login') {
8348+
$tableName = $this->getProperty('loginTable', $this->getProperty('usersTable', 'users'));
8349+
} else {
83488350
$tableName = $this->getProperty('usersTable', 'users');
8351+
}
83498352
$table = $this->reflection->getTable($tableName);
83508353
$usernameColumnName = $this->getProperty('usernameColumn', 'username');
83518354
$usernameColumn = $table->getColumn($usernameColumnName);

src/Tqdev/PhpCrudApi/Middleware/DbAuthMiddleware.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,13 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
6060
$username = isset($body->$usernameFormFieldName) ? $body->$usernameFormFieldName : '';
6161
$password = isset($body->$passwordFormFieldName) ? $body->$passwordFormFieldName : '';
6262
$newPassword = isset($body->$newPasswordFormFieldName) ? $body->$newPasswordFormFieldName : '';
63-
if ($path === 'login')
64-
$tableName = $this->getProperty('loginTable', 'users'); //add separate property for login as this could be a view joining users table to other table such as roles, details etc. At a minimum, the view output should include the $usernameColumn and $passwordColumn
65-
else
63+
//add separate property for login as this could be a view joining users table to other table
64+
//such as roles, details etc. At a minimum, the view output should include the $usernameColumn and $passwordColumn
65+
if ($path === 'login') {
66+
$tableName = $this->getProperty('loginTable', $this->getProperty('usersTable', 'users'));
67+
} else {
6668
$tableName = $this->getProperty('usersTable', 'users');
69+
}
6770
$table = $this->reflection->getTable($tableName);
6871
$usernameColumnName = $this->getProperty('usernameColumn', 'username');
6972
$usernameColumn = $table->getColumn($usernameColumnName);

0 commit comments

Comments
 (0)