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?
|
void |
setAuthenticationHandler
($handler)
Sets authentication handler.
|
void |
setAuthorizationHandler
($handler)
Sets authorization handler.
|
void |
Enables sign out after inactivity.
|
void |
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 void |
setAuthenticated
(bool $state)
Set the authenticated status of this user.
|
protected void |
setIdentity
([$identity =
NULL ])
|
Methods Inherited From Object |
---|
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset() |
Constant Summary | |||
---|---|---|---|
int | BROWSER_CLOSED |
3 |
line 41 sign-out reason User::getSignOutReason() |
int | INACTIVITY |
2 |
line 40 sign-out reason User::getSignOutReason() |
int | MANUAL |
1 |
line 39 sign-out reason User::getSignOutReason() |
Variable Summary | ||||
---|---|---|---|---|
string | $authenticatedRole | 'authenticated' |
line 48 default role for authenticated user without own identity |
|
string | $guestRole | 'guest' |
line 45 default role for unauthenticated user |
|
array | $onAuthenticated |
|
line 51 of event handlers; Occurs when the user is successfully authenticated; function(User $sender) |
|
array | $onSignedOut |
|
line 54 of event handlers; Occurs when the user is logged off; function(User $sender) |
Method Details | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
line 82 authenticatepublic void authenticate (string $username, string $password, [mixed $extra = Conducts the authentication process. Implementation of:
|
||||||||||||||||||||||||
line 163 getAuthenticationHandlerpublic IAuthenticator getAuthenticationHandler () Returns authentication handler. Implementation of:
|
||||||||||||||||||||||||
line 396 getAuthorizationHandlerpublic IAuthorizator getAuthorizationHandler () Returns current authorization handler. Implementation of:
|
||||||||||||||||||||||||
line 139 getIdentitypublic IIdentity getIdentity () Returns current user identity, if any. Implementation of:
|
||||||||||||||||||||||||
line 192 getNamespacepublic string getNamespace () Returns current namespace. Implementation of:
|
||||||||||||||||||||||||
line 333 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 242 getSessionNamespaceprotected SessionNamespace getSessionNamespace ($need) Returns and initializes $this->session.
|
||||||||||||||||||||||||
line 230 getSignOutReasonpublic int getSignOutReason () Why was user signed out?
|
||||||||||||||||||||||||
line 364 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 127 isAuthenticatedpublic bool isAuthenticated () Is this user authenticated? Implementation of:
|
||||||||||||||||||||||||
line 350 isInRolepublic bool isInRole (string $role) Is a user in the specified effective role? Implementation of:
|
||||||||||||||||||||||||
line 294 setAuthenticatedprotected void setAuthenticated (bool $state) Set the authenticated status of this user.
|
||||||||||||||||||||||||
line 152 setAuthenticationHandlerpublic void setAuthenticationHandler ($handler) Sets authentication handler. Implementation of:
|
||||||||||||||||||||||||
line 385 setAuthorizationHandlerpublic void setAuthorizationHandler ($handler) Sets authorization handler. Implementation of:
|
||||||||||||||||||||||||
line 206 setExpirationpublic void setExpiration (int $seconds, [bool $whenBrowserIsClosed = Enables sign out after inactivity.
|
||||||||||||||||||||||||
line 318 setIdentityprotected void setIdentity ([$identity =
|
||||||||||||||||||||||||
line 178 setNamespacepublic void setNamespace (string $namespace) Changes namespace; allows more users to share a session. Implementation of:
|
||||||||||||||||||||||||
line 109 signOutpublic void signOut ([bool $clearIdentity = Logs off the user from the current session. Implementation of:
|