class User extends Object

User authentication and authorization.

Constants

deprecated MANUAL

deprecated INACTIVITY

deprecated BROWSER_CLOSED

Properties

string $guestRole
string $authenticatedRole
callable[] $onLoggedIn
callable[] $onLoggedOut
IAuthenticator $authenticator
IAuthorizator $authorizator
bool read-only $loggedIn
IIdentity read-only $identity
mixed read-only $id
array read-only $roles
int read-only $logoutReason
IUserStorage read-only $storage

Methods

__construct(IUserStorage $storage, IAuthenticator $authenticator = NULL, IAuthorizator $authorizator = NULL)

No description

getStorage()

No description

void
login($id = NULL, $password = NULL)

Conducts the authentication process. Parameters are optional.

void
logout($clearIdentity = FALSE)

Logs out the user from the current session.

bool
isLoggedIn()

Is this user authenticated?

IIdentity|null
getIdentity()

Returns current user identity, if any.

mixed
getId()

Returns current user ID, if any.

setAuthenticator(IAuthenticator $handler)

Sets authentication handler.

getAuthenticator($need = TRUE)

Returns authentication handler.

setExpiration($time, $whenBrowserIsClosed = TRUE, $clearIdentity = FALSE)

Enables log out after inactivity.

int
getLogoutReason()

Why was user logged out?

array
getRoles()

Returns a list of effective roles that a user has been granted.

bool
isInRole($role)

Is a user in the specified effective role?

bool
isAllowed($resource = IAuthorizator::ALL, $privilege = IAuthorizator::ALL)

Has a user effective access to the Resource? If $resource is NULL, then the query applies to all resources.

setAuthorizator(IAuthorizator $handler)

Sets authorization handler.

getAuthorizator($need = TRUE)

Returns current authorization handler.

Details

at line 56
__construct(IUserStorage $storage, IAuthenticator $authenticator = NULL, IAuthorizator $authorizator = NULL)

No description

Parameters

IUserStorage $storage
IAuthenticator $authenticator
IAuthorizator $authorizator

at line 67
IUserStorage getStorage()

No description

Return Value

IUserStorage

at line 83
void login($id = NULL, $password = NULL)

Conducts the authentication process. Parameters are optional.

Parameters

$id
$password

Return Value

void

Exceptions

AuthenticationException

at line 100
void logout($clearIdentity = FALSE)

Logs out the user from the current session.

Parameters

$clearIdentity

Return Value

void

at line 116
bool isLoggedIn()

Is this user authenticated?

Return Value

bool

at line 126
IIdentity|null getIdentity()

Returns current user identity, if any.

Return Value

IIdentity|null

at line 136
mixed getId()

Returns current user ID, if any.

Return Value

mixed

at line 147
User setAuthenticator(IAuthenticator $handler)

Sets authentication handler.

Parameters

IAuthenticator $handler

Return Value

User

at line 158
IAuthenticator getAuthenticator($need = TRUE)

Returns authentication handler.

Parameters

$need

Return Value

IAuthenticator

at line 174
User setExpiration($time, $whenBrowserIsClosed = TRUE, $clearIdentity = FALSE)

Enables log out after inactivity.

Parameters

$time
$whenBrowserIsClosed
$clearIdentity

Return Value

User

at line 186
int getLogoutReason()

Why was user logged out?

Return Value

int

at line 199
array getRoles()

Returns a list of effective roles that a user has been granted.

Return Value

array

at line 215
bool isInRole($role)

Is a user in the specified effective role?

Parameters

$role

Return Value

bool

at line 228
bool isAllowed($resource = IAuthorizator::ALL, $privilege = IAuthorizator::ALL)

Has a user effective access to the Resource? If $resource is NULL, then the query applies to all resources.

Parameters

$resource
$privilege

Return Value

bool

at line 244
User setAuthorizator(IAuthorizator $handler)

Sets authorization handler.

Parameters

IAuthorizator $handler

Return Value

User

at line 255
IAuthorizator getAuthorizator($need = TRUE)

Returns current authorization handler.

Parameters

$need

Return Value

IAuthorizator