AuthContract
in
Authentication Contract
This interface defines the contract for authentication services. Implementations should provide methods for user authentication and session management.
Table of Contents
Methods
- get_instance() : mixed
- get_user() : mixed
- Get the currently authenticated user
- is_authenticated() : bool
- Check if a user is currently authenticated
- login() : bool
- Log out the currently authenticated user
- logout() : mixed
- Get the ID of the currently authenticated user
Methods
get_instance()
public
static get_instance() : mixed
get_user()
Get the currently authenticated user
public
get_user([mixed $id = 0 ]) : mixed
Parameters
- $id : mixed = 0
Return values
mixed —The user object or null if no user is authenticated
is_authenticated()
Check if a user is currently authenticated
public
is_authenticated() : bool
Return values
bool —True if a user is authenticated, false otherwise
login()
Log out the currently authenticated user
public
login([mixed $username_email = '' ][, mixed $password = '' ][, mixed $save_sessions = true ]) : bool
Parameters
- $username_email : mixed = ''
- $password : mixed = ''
- $save_sessions : mixed = true
Return values
bool —True if the logout was successful
logout()
Get the ID of the currently authenticated user
public
logout() : mixed
Return values
mixed —The user ID or null if no user is authenticated