1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-07-30 21:00:13 +02:00

Add internal method 'Auth#getOpenPasswordResetRequests'

This commit is contained in:
Marco
2016-08-20 18:07:18 +02:00
parent f4b464a6f8
commit 35cc941f20

View File

@@ -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
*