Class User (namespace Nette\Web)
Authentication and authorization.
Object | --User
Implements interfaces:
Public Method Summary | |
---|---|
void |
authenticate
(string $username, string $password, [mixed $extra =
NULL ])
Conducts the authentication process.
|
IAuthenticator |
Returns authentication handler.
|
IAuthorizator |
Returns current authorization handler.
|
IIdentity |
getIdentity
()
Returns current user identity, if any.
|
string |
getNamespace
()
Returns current namespace.
|
array |
getRoles
()
Returns a list of effective roles that a user has been granted.
|
int |
Why was user signed out?
|
bool |
Has a user effective access to the Resource? If $resource is NULL, then the query applies to all resources.
|
bool |
Is this user authenticated?
|
bool |
isInRole
(string $role)
Is a user in the specified effective role?
|
User |
setAuthenticationHandler
($handler)
Sets authentication handler.
|
User |
setAuthorizationHandler
($handler)
Sets authorization handler.
|
User |
setExpiration
(string|int|DateTime $time, [bool $whenBrowserIsClosed =
TRUE ], [bool $clearIdentity = FALSE ])
Enables sign out after inactivity.
|
User |
setNamespace
(string $namespace)
Changes namespace; allows more users to share a session.
|
void |
signOut
([bool $clearIdentity =
FALSE ])
Logs off the user from the current session.
|
Protected Method Summary | |
---|---|
protected Session |
getSession
()
Returns session handler.
|
protected SessionNamespace |
getSessionNamespace
($need)
Returns and initializes $this->session.
|
protected User |
setAuthenticated
(bool $state)
Sets the authenticated status of this user.
|
protected User |
setIdentity
([$identity =
NULL ])
Sets the user identity.
|
Methods Inherited From Object |
---|
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset() |
Constant Summary | |||
---|---|---|---|
int | BROWSER_CLOSED |
3 |
line 33 sign-out reason User::getSignOutReason() |
int | INACTIVITY |
2 |
line 32 sign-out reason User::getSignOutReason() |
int | MANUAL |
1 |
line 31 sign-out reason User::getSignOutReason() |
Variable Summary | ||||
---|---|---|---|---|
string | $authenticatedRole | 'authenticated' |
line 40 default role for authenticated user without own identity |
|
string | $guestRole | 'guest' |
line 37 default role for unauthenticated user |
|
array | $onAuthenticated |
|
line 43 of function(User $sender); Occurs when the user is successfully authenticated |
|
array | $onSignedOut |
|
line 46 of function(User $sender); Occurs when the user is logged off |
Method Details | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
line 74 authenticatepublic void authenticate (string $username, string $password, [mixed $extra = Conducts the authentication process. Implementation of:
|
||||||||||||||||||||||||
line 156 getAuthenticationHandlerpublic IAuthenticator getAuthenticationHandler () Returns authentication handler. Implementation of:
|
||||||||||||||||||||||||
line 396 getAuthorizationHandlerpublic IAuthorizator getAuthorizationHandler () Returns current authorization handler. Implementation of:
|
||||||||||||||||||||||||
line 131 getIdentitypublic IIdentity getIdentity () Returns current user identity, if any. Implementation of:
|
||||||||||||||||||||||||
line 186 getNamespacepublic string getNamespace () Returns current namespace. Implementation of:
|
||||||||||||||||||||||||
line 332 getRolespublic array getRoles () Returns a list of effective roles that a user has been granted. Implementation of:
|
||||||||||||||||||||||||
line 414 getSessionprotected Session getSession () Returns session handler.
|
||||||||||||||||||||||||
line 237 getSessionNamespaceprotected SessionNamespace getSessionNamespace ($need) Returns and initializes $this->session.
|
||||||||||||||||||||||||
line 225 getSignOutReasonpublic int getSignOutReason () Why was user signed out?
|
||||||||||||||||||||||||
line 363 isAllowedpublic bool isAllowed ([string $resource = Has a user effective access to the Resource? If $resource is NULL, then the query applies to all resources. Implementation of:
|
||||||||||||||||||||||||
line 119 isAuthenticatedpublic bool isAuthenticated () Is this user authenticated? Implementation of:
|
||||||||||||||||||||||||
line 349 isInRolepublic bool isInRole (string $role) Is a user in the specified effective role? Implementation of:
|
||||||||||||||||||||||||
line 290 setAuthenticatedprotected User setAuthenticated (bool $state) Sets the authenticated status of this user.
|
||||||||||||||||||||||||
line 144 setAuthenticationHandlerpublic User setAuthenticationHandler ($handler) Sets authentication handler. Implementation of:
|
||||||||||||||||||||||||
line 384 setAuthorizationHandlerpublic User setAuthorizationHandler ($handler) Sets authorization handler. Implementation of:
|
||||||||||||||||||||||||
line 200 setExpirationpublic User setExpiration (string|int|DateTime $time, [bool $whenBrowserIsClosed = Enables sign out after inactivity.
|
||||||||||||||||||||||||
line 316 setIdentityprotected User setIdentity ([$identity = Sets the user identity.
|
||||||||||||||||||||||||
line 171 setNamespacepublic User setNamespace (string $namespace) Changes namespace; allows more users to share a session. Implementation of:
|
||||||||||||||||||||||||
line 101 signOutpublic void signOut ([bool $clearIdentity = Logs off the user from the current session. Implementation of:
|