Documentation

User extends Auth
in package

Class User

Represents a user entity and provides methods for user management such as adding users, verifying login status, retrieving user details, resetting passwords, and checking user registration. Extends the Auth class to leverage authentication functionalities.

Table of Contents

Properties

$db  : MySql
$enc  : Encryption
$request  : Request
$role  : string
$session  : Session
$userData  : UserData

Methods

__construct()  : mixed
addUser()  : array<string|int, mixed>
Adds a new user
cleanAuthTable()  : void
Deletes redundant validator tokens
createUser()  : array<string|int, mixed>
Creates user
get()  : array<string|int, mixed>
getByUsername()  : type
getUserRoles()  : array<string|int, mixed>
Returns array with user's roles
hasRole()  : bool
Returns boolean indicating whether a use has particular role
isLogged()  : bool|array<string|int, mixed>
isRegistered()  : type
logIn()  : bool
Logs in a user
logOut()  : bool
Logs out the user
resetOwnPassword()  : bool
resetUserPassword()  : bool
Resets user's password
isAuth()  : bool|int
Checks whether the user is logged On success, SESSION is always closed for performance reasons
resetPasword()  : bool

Properties

$role

protected string $role = 'user'

Methods

addUser()

Adds a new user

public addUser(string $name, string $lastName, string $username, string $pwd, int $status) : array<string|int, mixed>
Parameters
$name : string
$lastName : string
$username : string
$pwd : string
$status : int
Return values
array<string|int, mixed>

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>

get()

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

getByUsername()

public getByUsername(string $username) : type
Parameters
$username : string
Tags
throws
Exception
Return values
type

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
bool

isLogged()

public isLogged() : bool|array<string|int, mixed>
Return values
bool|array<string|int, mixed>

isRegistered()

public isRegistered(string $username) : type
Parameters
$username : string
Return values
type

logIn()

Logs in a user

public logIn(string $username, string $pwd[, bool $remember = false ]) : bool
Parameters
$username : string
$pwd : string
$remember : bool = false
Return values
bool

logOut()

Logs out the user

public logOut() : bool
Return values
bool

resetOwnPassword()

public resetOwnPassword(int $userId, string $pwd[, bool $login = false ]) : bool
Parameters
$userId : int
$pwd : string
$login : bool = false
Return values
bool

resetUserPassword()

Resets user's password

public resetUserPassword(int $userId, string $pwd[, bool $login = false ]) : bool
Parameters
$userId : int
$pwd : string
$login : bool = false
Return values
bool

isAuth()

Checks whether the user is logged On success, SESSION is always closed for performance reasons

protected isAuth() : bool|int
Return values
bool|int

resetPasword()

protected resetPasword(int $userId, string $pwd[, bool $login = false ]) : bool
Parameters
$userId : int
$pwd : string
$login : bool = false
Return values
bool

        
On this page

Search results