Documentation

LoginAttemptManager
in package

LoginAttemptManager

Tracks and manages failed login attempts per IP address and email. Used by LoginController to apply conditional anti-brute-force logic with Google reCAPTCHA v2 when a threshold of failed attempts is reached.

Tags
version
1.0.0

Table of Contents

Properties

$pdo  : PDO

Methods

__construct()  : mixed
Initialize with database connection from Database singleton
clearAttempts()  : void
Remove all failed login attempt records for a given IP and email
countRecentAttempts()  : int
Count failed login attempts for a given IP and email within a time window
recordFailedAttempt()  : void
Record a new failed login attempt

Properties

Methods

__construct()

Initialize with database connection from Database singleton

public __construct() : mixed

clearAttempts()

Remove all failed login attempt records for a given IP and email

public clearAttempts(string $ip, string $email) : void

Called after a successful login to reset the brute-force counter.

Parameters
$ip : string

The client IP address

$email : string

The authenticated user's email address

Tags
throws
PDOException

If the database query fails

countRecentAttempts()

Count failed login attempts for a given IP and email within a time window

public countRecentAttempts(string $ip, string $email[, int $minutes = 15 ]) : int
Parameters
$ip : string

The client IP address

$email : string

The submitted email address

$minutes : int = 15

Size of the sliding window in minutes (default: 15)

Tags
throws
PDOException

If the database query fails

Return values
int

Number of failed attempts in the window

recordFailedAttempt()

Record a new failed login attempt

public recordFailedAttempt(string $ip, string $email) : void
Parameters
$ip : string

The client IP address

$email : string

The submitted email address

Tags
throws
PDOException

If the database query fails


        
On this page

Search results