Download the PHP package pavel852/php-auth without Composer
On this page you can find all versions of the php package pavel852/php-auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pavel852/php-auth
More information about pavel852/php-auth
Files in pavel852/php-auth
Package php-auth
Short Description Simple authentification system for PHP.
License MIT
Informations about the package php-auth
PHP Authentication Library
Overview
auth.php is a simple PHP authentication library that provides essential user authentication functionalities without relying on an internal database. It uses arrays to manage user data and MD5 for password hashing. The library includes features such as user registration, login, logout, password reset, and email verification.
Functions
auth_settings($params = "")
Sets the configuration parameters for the authentication library.
- Parameters:
$params(string): Configuration parameters in the format"key=value, key=value, ...".
- Usage:
auth_version()
Returns the current version of the authentication system.
- Returns:
- (string) The version number.
- Usage:
generateNumericPassword($length = 6)
Generates a random numeric password.
- Parameters:
$length(int): The number of digits in the password.
- Returns:
- (string) The generated numeric password.
- Usage:
generateToken()
Generates a random token.
- Returns:
- (string) A 32-character hexadecimal token.
- Usage:
auth_register($username, $password = null, $userid = null, $email = null)
Registers a new user.
- Parameters:
$username(string|array): Username or an array of user data.$password(string|null): Password (optional if email verification is enabled).$userid(mixed): User ID (optional).$email(string|null): Email address (optional).
- Returns:
- (array|bool|string) User data array on success or
trueif no email verification is required, otherwise an error message.
- (array|bool|string) User data array on success or
- Usage:
auth_login($identifier, $password, $user_data)
Logs in a user.
- Parameters:
$identifier(string|int): Username or User ID.$password(string): Password.$user_data(array): User data array.
- Returns:
- (bool|string)
trueon success, otherwise an error message.
- (bool|string)
- Usage:
auth_logout()
Logs out the current user.
- Returns:
- (void)
- Usage:
auth_request_password_reset($email, $user_data)
Requests a password reset.
- Parameters:
$email(string): User's email address.$user_data(array): User data array.
- Returns:
- (array|bool|string) Array with reset token and expiry on success, otherwise an error message.
- Usage:
auth_reset_password($token, $new_password, &$user_data)
Resets the user's password using a reset token.
- Parameters:
$token(string): Reset token.$new_password(string): New password.&$user_data(array): Reference to user data array.
- Returns:
- (bool|string)
trueon success, otherwise an error message.
- (bool|string)
- Usage:
auth_verify_email($token, &$user_data)
Verifies the user's email using a verification token.
- Parameters:
$token(string): Verification token.&$user_data(array): Reference to user data array.
- Returns:
- (array|bool|string)
trueon success or array with additional data if password verification is required, otherwise an error message.
- (array|bool|string)
- Usage:
auth_get_user()
Gets the currently logged-in user.
- Returns:
- (string|null) Username or
nullif not logged in.
- (string|null) Username or
- Usage:
auth_is_logged_in()
Checks if a user is currently logged in.
- Returns:
- (bool)
trueif logged in, otherwisefalse.
- (bool)
- Usage: