com\setasign\SetaSite\User

Users Class Users

File: /SetaSite/src/User/Users.php

Class hierarchy

Summary

Properties

$allowNullPasswords

$propertiesConfig

protected \com\setasign\SetaFramework\Config\Config Users::$propertiesConfig

$table

protected Users::$table

Static Methods

hashPassword()

public static Users::hashPassword (
string $password,
?string $salt = null
): string
Parameters
$password : string
 
$salt : ?string
 

Methods

__construct()

public Users::__construct (
\com\setasign\SetaSite\Config\UserProperties $userPropertiesConfig,
bool $allowNullPasswords,
\com\setasign\SetaFramework\Database\JoinedTable\JoinedTable $table
)
Parameters
$userPropertiesConfig : \com\setasign\SetaSite\Config\UserProperties
 
$allowNullPasswords : bool
 
$table : \com\setasign\SetaFramework\Database\JoinedTable\JoinedTable
 

checkLogin()

public Users::checkLogin (
int $userId,
int $timeout,
?string $sessionId = null,
?string $windowId = null,
bool $onlyActive = true
): User
Parameters
$userId : int
 
$timeout : int
 
$sessionId : ?string
 
$windowId : ?string
 
$onlyActive : bool

Use only active accounts. Param will ignored if $user is set.

Exceptions

Throws InvalidLoginException

create()

public Users::create (
void
): User

createUserObjectByRow()

public Users::createUserObjectByRow (
\com\setasign\SetaFramework\Database\Table\Row $row
): User
Parameters
$row : \com\setasign\SetaFramework\Database\Table\Row
 

getTable()

public Users::getTable (
void
): \com\setasign\SetaFramework\Database\JoinedTable\JoinedTable

getUserList()

public Users::getUserList (
void
): array

Returns a list with all users(id, firstname, lastname).

getUsernameById()

public Users::getUsernameById (
int $id,
bool $onlyActive = false
): mixed
Parameters
$id : int
 
$onlyActive : bool
 
Exceptions

Throws UnknownUserException

getUsernames()

public Users::getUsernames (
void
): array

Returns a list with all usernames (key = id).

loadByField()

public Users::loadByField (
string $fieldName,
string $value,
bool $onlyActive = true
): ?User
Parameters
$fieldName : string
 
$value : string
 
$onlyActive : bool
 

loadById()

public Users::loadById (
int $id,
bool $onlyActive = false
): User
Parameters
$id : int
 
$onlyActive : bool
 
Exceptions

Throws UnknownUserException

loadByLoginData()

public Users::loadByLoginData (
string $username,
string $password,
bool $onlyActive = true
): User
Parameters
$username : string
 
$password : string
 
$onlyActive : bool
 
Exceptions

Throws InvalidLoginException

loadMultipleByIds()

public Users::loadMultipleByIds (
int[] $ids,
bool $onlyActive = false
): array
Parameters
$ids : int[]
 
$onlyActive : bool
 

login()

public Users::login (
User $user,
string $sessionId,
string $windowId,
string $remoteAddr
): void

Login a user.

You will need to save the userId in your session.

Parameters
$user : User
 
$sessionId : string
 
$windowId : string
 
$remoteAddr : string
 
Exceptions

Throws UnknownUserException

logout()

public Users::logout (
int|User $user
): void

Logout a session

Parameters
$user : int|User

User object or user id

Exceptions

Throws \com\setasign\SetaSite\PropertyContainer\InvalidValueException If the user can't be saved because of an invalid value!

Throws UnknownUserException If the user can't be found!

save()

public Users::save (
User $user
): void
Parameters
$user : User
 
Exceptions

Throws \com\setasign\SetaSite\PropertyContainer\InvalidValueException