Description:
Creates an instance of the Auth class with the provided database connection and config class instance.
Parameters:
$pdo
: PDO Database connection$config
: An instance of the Config class
Returns:
Void
Description:
Authenticates a user with the system.
Note: Also installs a cookie named config->cookie_name
(see config)
Parameters:
$email
(string): User's email address$password
(string): User's password$remember
(boolean): Remember me checkbox value (temporary or permanent session)$captcha_response
(string, optional): captcha response code if needed, default NULL
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success messagehash
(string): The session hash to be stored in the session cookieexpire
(int): Timestamp of session expiry timecookie_name
(string): Cookie name from config
Description:
Handles the registration of a new user.
Parameters:
$email
(string): User's email address$password
(string): User's password$repeatpassword
(string): User's password confirmation$params
(array, optional): additional params to set in users table (attr_name => value), default Array()$captcha_response
(string, optional): captcha code if needed, default NULL$use_email_activation
(boolean, optional): enable/disable email activation, default NULL
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description:
Activates a user's account with the activation key sent via email
Parameters:
$key
(string): The user's activation key
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description:
Creates a password reset request for a given email address and sends email
Parameters:
$email
(string): User's email address$use_email_activation
(boolean, optional): enable/disable email activation, default NULL
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description:
Terminates a given session
Parameters:
$hash
(string): User's session hash
Returns:
- (boolean)
Description:
Hashes a given password using bcrypt
Parameters:
$password
(string): String to hash
Returns:
- (string)
Description:
Gets the user's ID associated with a given email address
Parameters:
$email
(string): User's email address
Returns:
$id
(int): User's ID
Description:
Creates a session for a given UID. Also installs a cookie named config->cookie_name
.
Parameters:
$uid
(int): User's ID$remember
(boolean): Remember me checkbox value (temporary or permanent session)
Returns:
$data
(array)hash
(string): The session hash to be stored in the session cookieexpire
(int): Timestamp of session expiry timecookie_crc
(string): CRC created from hash andconfig->site_key
Description:
Deletes all existing sessions for a given UID
Parameters:
$uid
(int): User's ID
Returns:
- (boolean)
Description:
Deletes the session associated with a given session hash
Parameters:
$hash
(string): The session hash
Returns:
- (boolean)
Description: Checks if a session hash is valid (i.e. it exists in the session table, it hasn't expired, and the user's IP address matches the database entry)
Parameters:
$hash
(string): The session hash
Returns:
- (boolean)
Description: Retrieves the UID associated with a given session hash
Parameters:
$hash
(string): The session hash
Returns:
$uid
(int): User's ID
Description:
Checks if an email is already in use by another user
Parameters:
$email
(string): An email address
Returns:
- (boolean)
Description:
Checks if an email is banned
Parameters:
$email
(string): An email address
Returns:
- (boolean)
Description:
Adds a new user to the database
Parameters:
$email
(string): User's email address$password
(string): User's password$params
(array, optional): additional params to set in users table (attr_name => value), default Array()$use_email_activation
(boolean, optional): enable/disable email activation
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description: Gets basic user data for a given UID
Parameters:
$uid
(int): User's ID
Returns:
$data
(array)email
(string): User's email addresspassword
(string): User's passwordisactive
(boolean): Is user's account activateduid
(int): User's ID
Description: Gets user data for a given UID
Parameters:
$uid
(int): User's ID$withpassword
(boolean, optional): Whether to include the user's password in the returned data array, default false (Note:password
returned is bcrypt-encrypted hash, not their actual password)
Returns:
$data
(array)email
(string): User's email addresspassword
(string): User's passwordisactive
(boolean): Is user's account activateduid
(int): User's ID
Description: Delete's a user's account, sessions and requests
Parameters:
$uid
(int): User's ID$password
(string): User's password$captcha_response
(string, optional): captcha response code if needed, default NULL
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description: Force delete user without password or captcha verification
Parameters:
$uid
(int): User's ID
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description: Creates a new password reset / activation request for a given user and sends the email
Parameters:
$uid
(int): User's ID$email
(string): User's email address$type
(string): Type of request (activation
orreset
)$use_email_activation
(boolean, optional): enable/disable email activation, default undefined
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description: Returns request data based on request key and type
Parameters:
$key
(string): Request key$type
(string): Type of request (activation
orreset
)
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notid
(int): Request IDuid
(int): User's ID
Description: Deletes a request by request ID
Parameters:
$id
(int): Request ID
Returns:
- (boolean)
Description: Checks if a password meets specific length
Parameters:
$password
(string): User's password
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description: Checks if an email address is valid and is not banned
Parameters:
$email
(string): User's email address
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description: Allows a user to change their password with a password reset request key
Parameters:
$key
(string): Request key$password
(string): User's password$repeatpassword
(string): User's password confirmation$captcha_response
(string, optional): captcha response code if needed, default NULL
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description: Recreates activation email for a given email and sends
Parameters:
$email
(string): User's email address$use_email_activation
(boolean, optional): enable/disable email activation, default null
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description: Changes a user's password
Parameters:
$uid
(int): User's ID$currpass
(string): User's current password$newpass
(string): User's new password$repeatnewpass
(string): User's new password confirmation$captcha_response
(string, optional): captcha response code if needed, default NULL
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description: Changes a user's email address
Parameters:
$uid
(int): User's ID$email
(string): User's new email address$password
(string): User's password$captcha
(string, optional): captcha response code if needed, default NULL
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description: Checks if the current IP is temporarily blocked from the system
Parameters:
Void
Returns:
- (boolean)
Description:
Verifies a captcha code. (Currently returns true
for any value.)
Parameters:
$captcha
(string, optional): captcha response code
Returns:
- (boolean)
Description: Check Google Recaptcha code. If reCaptcha disabled in config or config not defined - return TRUE (captcha passed)
Parameters:
$captcha_response
(string, optional): captcha response code
Returns:
- (boolean)
Description: Adds an attempt to database for the current IP
Parameters:
Void
Returns:
- (boolean)
Description: Deletes attempts (all attempts or expired ones) for a given IP from database
Parameters:
$ip
(string): User's IP$all
(boolean): If true, delete all attempts. If false, delete all expired attempts.
Returns:
- (boolean)
Description: Provides a randomly generated string
Parameters:
$length
(int): Randomly generated string length, default 20
Returns:
$key
(string): Randomly generated string
Description: Provides the current user's IP
Parameters:
Void
Returns:
$ip
(string): User's IP
Description: Returns current session hash
Parameters:
Void
Returns:
hash
(string): Current session hash
Description: Returns is user logged in
Parameters:
Void
Returns:
- (boolean)
Description: Gets user data for current user (from cookie/session_hash) and returns an array, password is not returned
Parameters:
Void
Returns:
- (array, or false if no current user)
Description: Compare user's password with given password
Parameters:
$userid
(int): User's ID$password_for_check
(string): User's password
Returns:
- (boolean)
Description: Compare user's password with given password
Parameters:
$userid
(int): User's ID$password_for_check
(string): User's password
Returns:
- (boolean)
Description:
Verifies the entered password against the stored hash. If the bcrypt_cost
setting are now stronger than when the password was originally hashed and stored in the database, the password will be rehashed and the database-entry replaced by the new value.
Parameters:
$password
(string): Password to verify.$hash
(string): Hash to to verify password against.$uid
(int): User's id.
Returns:
- (boolean)
Description: Send email via PHPMailer.
Parameters:
$email
(string): Destination email address$type
(string): 'activation' or 'reset'$key
(string): Random string key
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description:
Updates a user info at the database
Parameters:
$uid
(int): User id$params
(array) User data
Returns:
$return
(array)error
(boolean): Informs whether an error was encountered or notmessage
(string): User-friendly error / success message
Description:
Returns current user UID if logged or FALSE otherwise.
Returns:
$return
(int): user UID