User
class User
User authentication and authorization.
Constants
deprecated MANUAL |
|
deprecated INACTIVITY |
|
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 |
Methods
No description
No description
Logs out the user from the current session.
Is this user authenticated?
Returns current user identity, if any.
Returns current user ID, if any.
No description
Returns authentication handler.
Returns authentication handler.
Enables log out after inactivity (like '20 minutes'). Accepts flag IUserStorage::CLEAR_IDENTITY.
Why was user logged out?
Returns a list of effective roles that a user has been granted.
Is a user in the specified effective role?
Has a user effective access to the Resource? If $resource is null, then the query applies to all resources.
Returns current authorization handler.
Returns current authorization handler.
Details
at line 63
__construct(IUserStorage $storage, IAuthenticator $authenticator = null, IAuthorizator $authorizator = null)
No description
at line 74
final IUserStorage
getStorage()
No description
at line 88
void
login(string|IIdentity $user, string $password = null)
Conducts the authentication process. Parameters are optional.
at line 105
final void
logout(bool $clearIdentity = false)
Logs out the user from the current session.
at line 122
final bool
isLoggedIn()
Is this user authenticated?
at line 134
final IIdentity|null
getIdentity()
Returns current user identity, if any.
at line 154
mixed
getId()
Returns current user ID, if any.
at line 161
final void
refreshStorage()
No description
at line 171
User
setAuthenticator(IAuthenticator $handler)
Sets authentication handler.
at line 181
final IAuthenticator|null
getAuthenticator()
Returns authentication handler.
at line 197
final IAuthenticator|null
getAuthenticatorIfExists()
Returns authentication handler.
at line 204
final bool
hasAuthenticator()
deprecated
deprecated
No description
at line 216
User
setExpiration(string|null $expire, int $flags = 0)
Enables log out after inactivity (like '20 minutes'). Accepts flag IUserStorage::CLEAR_IDENTITY.
at line 237
final int|null
getLogoutReason()
Why was user logged out?
at line 249
array
getRoles()
Returns a list of effective roles that a user has been granted.
at line 263
final bool
isInRole(string $role)
Is a user in the specified effective role?
at line 273
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.
at line 289
User
setAuthorizator(IAuthorizator $handler)
Sets authorization handler.
at line 299
final IAuthorizator|null
getAuthorizator()
Returns current authorization handler.
at line 315
final IAuthorizator|null
getAuthorizatorIfExists()
Returns current authorization handler.
at line 322
final bool
hasAuthorizator()
deprecated
deprecated
No description
Traits
Strict class for better experience.