Skip to content

Commit

Permalink
Restore checkPassword() function
Browse files Browse the repository at this point in the history
Signed-off-by: Git'Fellow <[email protected]>
  • Loading branch information
solracsf committed Apr 2, 2024
1 parent 5c6d982 commit ec78c92
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/UserBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,34 @@ public function implementsActions($actions) {
return (bool)($availableActions & $actions);
}

/**
* Check if the provided token is correct
* @param string $uid The username
* @param string $password The password
* @return string
*
* Check if the password is correct without logging in the user
* returns the user id or false
*/
public function checkPassword($uid, $password) {
$qb = $this->db->getQueryBuilder();
$qb->select('token')
->from('user_saml_auth_token')
->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid)))
->setMaxResults(1000);
$result = $qb->execute();
$data = $result->fetchAll();
$result->closeCursor();

foreach ($data as $passwords) {
if (password_verify($password, $passwords['token'])) {
return $uid;
}
}

return false;
}

/**
* delete a user
* @param string $uid The username of the user to delete
Expand Down

0 comments on commit ec78c92

Please sign in to comment.