Skip to content

Commit

Permalink
fix for #952
Browse files Browse the repository at this point in the history
  • Loading branch information
mevdschee committed Feb 1, 2023
1 parent 57d6859 commit 92478e1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
9 changes: 6 additions & 3 deletions api.include.php
Expand Up @@ -8342,10 +8342,13 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$username = isset($body->$usernameFormFieldName) ? $body->$usernameFormFieldName : '';
$password = isset($body->$passwordFormFieldName) ? $body->$passwordFormFieldName : '';
$newPassword = isset($body->$newPasswordFormFieldName) ? $body->$newPasswordFormFieldName : '';
if ($path === 'login')
$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
else
//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
if ($path === 'login') {
$tableName = $this->getProperty('loginTable', $this->getProperty('usersTable', 'users'));
} else {
$tableName = $this->getProperty('usersTable', 'users');
}
$table = $this->reflection->getTable($tableName);
$usernameColumnName = $this->getProperty('usernameColumn', 'username');
$usernameColumn = $table->getColumn($usernameColumnName);
Expand Down
9 changes: 6 additions & 3 deletions api.php
Expand Up @@ -8342,10 +8342,13 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$username = isset($body->$usernameFormFieldName) ? $body->$usernameFormFieldName : '';
$password = isset($body->$passwordFormFieldName) ? $body->$passwordFormFieldName : '';
$newPassword = isset($body->$newPasswordFormFieldName) ? $body->$newPasswordFormFieldName : '';
if ($path === 'login')
$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
else
//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
if ($path === 'login') {
$tableName = $this->getProperty('loginTable', $this->getProperty('usersTable', 'users'));
} else {
$tableName = $this->getProperty('usersTable', 'users');
}
$table = $this->reflection->getTable($tableName);
$usernameColumnName = $this->getProperty('usernameColumn', 'username');
$usernameColumn = $table->getColumn($usernameColumnName);
Expand Down
9 changes: 6 additions & 3 deletions src/Tqdev/PhpCrudApi/Middleware/DbAuthMiddleware.php
Expand Up @@ -60,10 +60,13 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$username = isset($body->$usernameFormFieldName) ? $body->$usernameFormFieldName : '';
$password = isset($body->$passwordFormFieldName) ? $body->$passwordFormFieldName : '';
$newPassword = isset($body->$newPasswordFormFieldName) ? $body->$newPasswordFormFieldName : '';
if ($path === 'login')
$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
else
//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
if ($path === 'login') {
$tableName = $this->getProperty('loginTable', $this->getProperty('usersTable', 'users'));
} else {
$tableName = $this->getProperty('usersTable', 'users');
}
$table = $this->reflection->getTable($tableName);
$usernameColumnName = $this->getProperty('usernameColumn', 'username');
$usernameColumn = $table->getColumn($usernameColumnName);
Expand Down

0 comments on commit 92478e1

Please sign in to comment.