Documentation

Authable

Table of Contents

Methods

authenticate()  : array<string|int, mixed>
The function authenticate() checks if a user with a given token exists, is active, and returns user information if authenticated.
login()  : array<string|int, mixed>
The login function in PHP checks user credentials, retrieves user information, and returns an array with authentication details if successful.

Methods

authenticate()

The function authenticate() checks if a user with a given token exists, is active, and returns user information if authenticated.

public authenticate(string $token) : array<string|int, mixed>

The function checks if a user with the provided token exists in the database. If the user is found and is active, it retrieves user information such as username, fullname, role, admin status, permissions, and user

Parameters
$token : string
Return values
array<string|int, mixed>

An array is being returned. If the user is authenticated successfully, the array will contain user information such as username, fullname, role, admin status, permissions, and user. If error, return array contains error_msg.

login()

The login function in PHP checks user credentials, retrieves user information, and returns an array with authentication details if successful.

public login(string $login, string $pass) : array<string|int, mixed>
Parameters
$login : string
$pass : string
Return values
array<string|int, mixed>

If the user is authenticated successfully, the array will contain user information such as username, fullname, role, admin status, permissions, and user.

return [
    'authed' => true,
    'user' => [ // will be put in SESSION
        'username' => $user['login'],
        'fullname' => $user['fullname'],
        'group' => $user['role'],
        'group_name' => $role_names,
        'is_admin' => $is_admin,
        'permissions' => $permissions,
        'type' => 'user',
     ]
 ];

if error, return

['error_msg' => t('error message ...')];

        
On this page

Search results