Auth
in package
Table of Contents
Properties
Methods
- __construct() : mixed
- cleanAuthTable() : void
- Deletes redundant validator tokens
- createUser() : array<string|int, mixed>
- Creates user
- getUserRoles() : array<string|int, mixed>
- Returns array with user's roles
- hasRole() : bool
- Returns boolean indicating whether a use has particular role
- logIn() : bool
- Logs in a user
- logOut() : bool
- Logs out the user
- isAuth() : bool|int
- Checks whether the user is logged On success, SESSION is always closed for performance reasons
- resetPasword() : bool
- cookieAuthRow() : array<string|int, mixed>|null
- Returns id and user_id from auth_user identified using COOKIE data
- cookieDomain() : string
- Returns the domain to be used for setcookie function
- generateToken() : string
- Generates validator token
- storageName() : string
- SESSION/COOKIE storage name
- updateLastLogin() : void
- Updates user last login time
Properties
$db
protected
MySql
$db
$enc
protected
Encryption
$enc
$request
protected
Request
$request
$role
protected
string
$role
= ''
$session
protected
Session
$session
Methods
__construct()
public
__construct(Database $db, Encryption $enc, Session $session, Request $request) : mixed
Parameters
- $db : Database
- $enc : Encryption
- $session : Session
- $request : Request
cleanAuthTable()
Deletes redundant validator tokens
public
cleanAuthTable(int $userId) : void
Parameters
- $userId : int
createUser()
Creates user
public
createUser(string $firstName, string $lastName, string $username, string $pwd[, int $status = 1 ]) : array<string|int, mixed>
Parameters
- $firstName : string
- $lastName : string
- $username : string
- $pwd : string
- $status : int = 1
Return values
array<string|int, mixed>getUserRoles()
Returns array with user's roles
public
getUserRoles(int $userId) : array<string|int, mixed>
Parameters
- $userId : int
Return values
array<string|int, mixed>hasRole()
Returns boolean indicating whether a use has particular role
public
hasRole(int $userId, string $role) : bool
Parameters
- $userId : int
- $role : string
Return values
boollogIn()
Logs in a user
public
logIn(string $username, string $pwd[, bool $remember = false ]) : bool
Parameters
- $username : string
- $pwd : string
- $remember : bool = false
Return values
boollogOut()
Logs out the user
public
logOut() : bool
Return values
boolisAuth()
Checks whether the user is logged On success, SESSION is always closed for performance reasons
protected
isAuth() : bool|int
Return values
bool|intresetPasword()
protected
resetPasword(int $userId, string $pwd[, bool $login = false ]) : bool
Parameters
- $userId : int
- $pwd : string
- $login : bool = false
Return values
boolcookieAuthRow()
Returns id and user_id from auth_user identified using COOKIE data
private
cookieAuthRow(string $storageName) : array<string|int, mixed>|null
Parameters
- $storageName : string
Return values
array<string|int, mixed>|nullcookieDomain()
Returns the domain to be used for setcookie function
private
cookieDomain() : string
Return values
stringgenerateToken()
Generates validator token
private
generateToken() : string
Return values
stringstorageName()
SESSION/COOKIE storage name
private
storageName() : string
Return values
stringupdateLastLogin()
Updates user last login time
private
updateLastLogin(int $userId) : void
Parameters
- $userId : int