mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-02 14:17:26 +02:00
Add internal method 'Auth#getOpenPasswordResetRequests'
This commit is contained in:
20
src/Auth.php
20
src/Auth.php
@@ -629,6 +629,26 @@ class Auth {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of open requests for a password reset by the specified user
|
||||||
|
*
|
||||||
|
* @param int $userId the ID of the user to check the requests for
|
||||||
|
* @return int the number of open requests for a password reset
|
||||||
|
* @throws AuthError if an internal problem occurred (do *not* catch)
|
||||||
|
*/
|
||||||
|
private function getOpenPasswordResetRequests($userId) {
|
||||||
|
$stmt = $this->db->prepare("SELECT COUNT(*) FROM users_resets WHERE user = :userId AND expires > :expiresAfter");
|
||||||
|
$stmt->bindValue(':userId', $userId, \PDO::PARAM_INT);
|
||||||
|
$stmt->bindValue(':expiresAfter', time(), \PDO::PARAM_INT);
|
||||||
|
|
||||||
|
if ($stmt->execute()) {
|
||||||
|
return $stmt->fetchColumn();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new DatabaseError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether the user is currently logged in and updates the session
|
* Sets whether the user is currently logged in and updates the session
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user