Skip to content

Commit

Permalink
fix for #858
Browse files Browse the repository at this point in the history
  • Loading branch information
mevdschee committed Feb 26, 2022
1 parent 5a376ab commit edd72db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion api.include.php
Expand Up @@ -7963,7 +7963,11 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if (strlen($newPassword) < $passwordLength) {
return $this->responder->error(ErrorCode::PASSWORD_TOO_SHORT, $passwordLength);
}
$users = $this->db->selectAll($table, $columnNames, $condition, $columnOrdering, 0, 1);
$userColumns = $columnNames;
if(!in_array($pkName, $columnNames)){
array_push($userColumns, $pkName);
}
$users = $this->db->selectAll($table, $userColumns, $condition, $columnOrdering, 0, 1);
foreach ($users as $user) {
if (password_verify($password, $user[$passwordColumnName]) == 1) {
if (!headers_sent()) {
Expand All @@ -7972,6 +7976,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$data = [$passwordColumnName => password_hash($newPassword, PASSWORD_DEFAULT)];
$this->db->updateSingle($table, $data, $user[$pkName]);
unset($user[$passwordColumnName]);
if(!in_array($pkName, $columnNames)){
unset($user[$pkName]);
}
return $this->responder->success($user);
}
}
Expand Down
9 changes: 8 additions & 1 deletion api.php
Expand Up @@ -7963,7 +7963,11 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if (strlen($newPassword) < $passwordLength) {
return $this->responder->error(ErrorCode::PASSWORD_TOO_SHORT, $passwordLength);
}
$users = $this->db->selectAll($table, $columnNames, $condition, $columnOrdering, 0, 1);
$userColumns = $columnNames;
if(!in_array($pkName, $columnNames)){
array_push($userColumns, $pkName);
}
$users = $this->db->selectAll($table, $userColumns, $condition, $columnOrdering, 0, 1);
foreach ($users as $user) {
if (password_verify($password, $user[$passwordColumnName]) == 1) {
if (!headers_sent()) {
Expand All @@ -7972,6 +7976,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$data = [$passwordColumnName => password_hash($newPassword, PASSWORD_DEFAULT)];
$this->db->updateSingle($table, $data, $user[$pkName]);
unset($user[$passwordColumnName]);
if(!in_array($pkName, $columnNames)){
unset($user[$pkName]);
}
return $this->responder->success($user);
}
}
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit edd72db

Please sign in to comment.