Login
extends KBase
in package
This class is responsible for handling user login functionality.
Tags
Table of Contents
- $from_submit : bool
- Indicates whether the login request is submitted.
- $login_input : string
- The name of the input field to be focused.
- $login_message : string
- The login message.
- $login_params : array<string|int, mixed>
- The login parameters submitted by the user.
- $cfg : object
- Config class instance.
- $request : Request
- Server request class instance.
- checkLogin() : string|array<string|int, mixed>
- Validates the login credentials against the configured username and password.
- checkStatus() : array<string|int, mixed>|null
- Check the status of a login.
- create() : static
- Validates the login request and performs the login process.
- forgot() : void
- Initiates the password recovery process.
- isAdmin() : array<string|int, mixed>|null
- Checks if the user is an admin.
- isMember() : array<string|int, mixed>|null
- Checks if the user is a member.
- login() : void
- Validates the login credentials and performs the login process.
- logout() : void
- Logs out the user by clearing the session and displaying a success message.
Properties
$from_submit
Indicates whether the login request is submitted.
public
static bool
$from_submit
= false
$login_input
The name of the input field to be focused.
public
static string
$login_input
Can be 'login_username' or 'login_password'.
$login_message
The login message.
public
static string
$login_message
$login_params
The login parameters submitted by the user.
public
static array<string|int, mixed>
$login_params
= []
$cfg
Config class instance.
protected
static object
$cfg
$request
Server request class instance.
protected
static Request
$request
Methods
checkLogin()
Validates the login credentials against the configured username and password.
public
checkLogin(array<string|int, mixed> $loginParams) : string|array<string|int, mixed>
Parameters
- $loginParams : array<string|int, mixed>
-
The login parameters. e.g., array('username' => '', 'password' => '');
Return values
string|array<string|int, mixed> —Returns a string error message if login fails, or an array with login information.
checkStatus()
Check the status of a login.
public
static checkStatus(array<string|int, mixed> $login, mixed $statuses) : array<string|int, mixed>|null
If the login is empty or the status does not match the provided statuses, null is returned. If the status matches, the login is returned.
Parameters
- $login : array<string|int, mixed>
-
The login information.
- $statuses : mixed
-
The allowed status(es) to check against.
Return values
array<string|int, mixed>|null —The login information if the status matches, null otherwise.
create()
Validates the login request and performs the login process.
public
static create(Request $request) : static
Parameters
- $request : Request
-
The HTTP request object.
Return values
static —forgot()
Initiates the password recovery process.
public
forgot(Request $request) : void
Parameters
- $request : Request
-
The HTTP request object.
Return values
void —isAdmin()
Checks if the user is an admin.
public
static isAdmin() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —Returns the login information if the user is an admin, or null otherwise.
isMember()
Checks if the user is a member.
public
static isMember() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —Returns the login information if the user is a member, or null otherwise.
login()
Validates the login credentials and performs the login process.
public
login(Request $request, array<string|int, mixed> $loginParams) : void
Parameters
- $request : Request
-
The HTTP request object.
- $loginParams : array<string|int, mixed>
-
The login parameters.
Return values
void —logout()
Logs out the user by clearing the session and displaying a success message.
public
logout(Request $request) : void
Parameters
- $request : Request
-
The HTTP request object.