Class User (namespace Nette\Web)
User authentication and authorization.
Object | --User
Implements interfaces:
Public Method Summary | |
---|---|
User |
__construct
()
|
void |
authenticate
($username, $password, [$extra =
NULL ])
deprecated method - use login(), logout(), isLoggedIn()
|
IAuthenticator |
Returns authentication handler.
|
IAuthorizator |
Returns current authorization handler.
|
IIdentity |
getIdentity
()
Returns current user identity, if any.
|
int |
Why was user logged out?
|
string |
getNamespace
()
Returns current namespace.
|
array |
getRoles
()
Returns a list of effective roles that a user has been granted.
|
void |
deprecated method - use login(), logout(), isLoggedIn()
|
bool |
Has a user effective access to the Resource? If $resource is NULL, then the query applies to all resources.
|
void |
deprecated method - use login(), logout(), isLoggedIn()
|
bool |
isInRole
(string $role)
Is a user in the specified effective role?
|
bool |
isLoggedIn
()
Is this user authenticated?
|
void |
login
(string $username, string $password, [mixed $extra =
NULL ])
Conducts the authentication process.
|
void |
logout
([bool $clearIdentity =
FALSE ])
Logs out the user from the current session.
|
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 log out after inactivity.
|
User |
setNamespace
(string $namespace)
Changes namespace; allows more users to share a session.
|
void |
signOut
([$clearIdentity =
FALSE ])
deprecated method - use login(), logout(), isLoggedIn()
|
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 log-out reason User::getLogoutReason() |
int | INACTIVITY |
2 |
line 32 log-out reason User::getLogoutReason() |
int | MANUAL |
1 |
line 31 log-out reason User::getLogoutReason() |
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 |
|
mixed | $onAuthenticated |
|
line 49 |
|
array | $onLoggedIn |
|
line 43 of function(User $sender); Occurs when the user is successfully logged in |
|
array | $onLoggedOut |
|
line 46 of function(User $sender); Occurs when the user is logged out |
|
mixed | $onSignedOut |
|
line 52 |
Method Details | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
line 68 __constructpublic User __construct ()
|
||||||||||||||||||||||||
line 437 authenticatepublic void authenticate ($username, $password, [$extra = deprecated method - use login(), logout(), isLoggedIn()
|
||||||||||||||||||||||||
line 171 getAuthenticationHandlerpublic IAuthenticator getAuthenticationHandler () Returns authentication handler. Implementation of:
|
||||||||||||||||||||||||
line 411 getAuthorizationHandlerpublic IAuthorizator getAuthorizationHandler () Returns current authorization handler. Implementation of:
|
||||||||||||||||||||||||
line 146 getIdentitypublic IIdentity getIdentity () Returns current user identity, if any. Implementation of:
|
||||||||||||||||||||||||
line 240 getLogoutReasonpublic int getLogoutReason () Why was user logged out?
|
||||||||||||||||||||||||
line 201 getNamespacepublic string getNamespace () Returns current namespace. Implementation of:
|
||||||||||||||||||||||||
line 347 getRolespublic array getRoles () Returns a list of effective roles that a user has been granted. Implementation of:
|
||||||||||||||||||||||||
line 429 getSessionprotected Session getSession () Returns session handler.
|
||||||||||||||||||||||||
line 252 getSessionNamespaceprotected SessionNamespace getSessionNamespace ($need) Returns and initializes $this->session.
|
||||||||||||||||||||||||
line 452 getSignOutReasonpublic void getSignOutReason () deprecated method - use login(), logout(), isLoggedIn() |
||||||||||||||||||||||||
line 378 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 447 isAuthenticatedpublic void isAuthenticated () deprecated method - use login(), logout(), isLoggedIn() |
||||||||||||||||||||||||
line 364 isInRolepublic bool isInRole (string $role) Is a user in the specified effective role? Implementation of:
|
||||||||||||||||||||||||
line 134 isLoggedInpublic bool isLoggedIn () Is this user authenticated? Implementation of:
|
||||||||||||||||||||||||
line 89 loginpublic void login (string $username, string $password, [mixed $extra = Conducts the authentication process. Implementation of:
|
||||||||||||||||||||||||
line 116 logoutpublic void logout ([bool $clearIdentity = Logs out the user from the current session. Implementation of:
|
||||||||||||||||||||||||
line 305 setAuthenticatedprotected User setAuthenticated (bool $state) Sets the authenticated status of this user.
|
||||||||||||||||||||||||
line 159 setAuthenticationHandlerpublic User setAuthenticationHandler ($handler) Sets authentication handler. Implementation of:
|
||||||||||||||||||||||||
line 399 setAuthorizationHandlerpublic User setAuthorizationHandler ($handler) Sets authorization handler. Implementation of:
|
||||||||||||||||||||||||
line 215 setExpirationpublic User setExpiration (string|int|DateTime $time, [bool $whenBrowserIsClosed = Enables log out after inactivity.
|
||||||||||||||||||||||||
line 331 setIdentityprotected User setIdentity ([$identity = Sets the user identity.
|
||||||||||||||||||||||||
line 186 setNamespacepublic User setNamespace (string $namespace) Changes namespace; allows more users to share a session. Implementation of:
|
||||||||||||||||||||||||
line 442 signOutpublic void signOut ([$clearIdentity = deprecated method - use login(), logout(), isLoggedIn()
|