Class User (namespace Nette\Web)


Authentication and authorization.

Object
   |
   --User

Implements interfaces:

IUser
Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /Web/User.php (line 40)
Method Summary
void
authenticate (string $username, string $password, [mixed $extra = NULL])
Conducts the authentication process.
IAuthenticator
Returns authentication handler.
IAuthorizator
Returns current authorization handler.
protected IHttpRequest
protected IHttpResponse
IIdentity
Returns current user identity, if any.
string
Returns current namespace.
array
Returns a list of roles that a user has been granted.
protected Session
Returns session handler.
protected SessionNamespace
Returns and initializes $this->session.
int
Why was user signed out?
bool
isAllowed ([string $resource = NULL], [string $privilege = NULL])
Has a user 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 role?
protected void
setAuthenticated (bool $state)
Set the authenticated status of this user.
void
Sets authentication handler.
void
Sets authorization handler.
void
setExpiration (int $seconds, [bool $whenBrowserIsClosed = TRUE], [bool $clearIdentity = FALSE])
Enables sign out after inactivity.
protected void
setIdentity ([$identity = NULL])
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.
Methods Inherited From Object
Object::extensionMethod(), Object::getClass(), Object::getReflection(), Object::__call(), Object::__callStatic(), Object::__get(), Object::__isset(), Object::__set(), Object::__unset()
Constant Summary
int BROWSER_CLOSED 3

line 45

sign-out reason User::getSignOutReason()
int INACTIVITY 2

line 44

sign-out reason User::getSignOutReason()
int MANUAL 1

line 43

sign-out reason User::getSignOutReason()
Variable Summary
string $authenticatedRole 'authenticated'

line 52

default role for authenticated user without own identity
string $guestRole 'guest'

line 49

default role for unauthenticated user
array $onAuthenticated

line 55

of event handlers; Occurs when the user is successfully authenticated; function(User $sender)
array $onSignedOut

line 58

of event handlers; Occurs when the user is logged off; function(User $sender)

Method Details

line 86

authenticate

public void authenticate (string $username, string $password, [mixed $extra = NULL])

Conducts the authentication process.

Implementation of:

Input
string $username
string $password
mixed $extra
Output
void  
Throws
throws AuthenticationException if authentication was not successful

line 167

getAuthenticationHandler

public IAuthenticator getAuthenticationHandler ()

Returns authentication handler.

Output
IAuthenticator  

line 416

getAuthorizationHandler

public IAuthorizator getAuthorizationHandler ()

Returns current authorization handler.

Output
IAuthorizator  

line 444

getHttpRequest

protected IHttpRequest getHttpRequest ()

Output
IHttpRequest  

line 454

getHttpResponse

protected IHttpResponse getHttpResponse ()

Output
IHttpResponse  

line 143

getIdentity

public IIdentity getIdentity ()

Returns current user identity, if any.

Implementation of:

Output
IIdentity  

line 196

getNamespace

public string getNamespace ()

Returns current namespace.

Implementation of:

Output
string  

line 353

getRoles

public array getRoles ()

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

Implementation of:

Output
array  

line 434

getSession

protected Session getSession ()

Returns session handler.

Output
Session  

line 246

getSessionNamespace

protected SessionNamespace getSessionNamespace ($need)

Returns and initializes $this->session.

Input
$need
Output
SessionNamespace  

line 234

getSignOutReason

public int getSignOutReason ()

Why was user signed out?

Output
int  

line 384

isAllowed

public bool isAllowed ([string $resource = NULL], [string $privilege = NULL])

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

Implementation of:

Input
string $resource resource
string $privilege privilege
Output
bool  

line 131

isAuthenticated

public bool isAuthenticated ()

Is this user authenticated?

Implementation of:

Output
bool  

line 370

isInRole

public bool isInRole (string $role)

Is a user in the specified role?

Implementation of:

Input
string $role
Output
bool  

line 305

setAuthenticated

protected void setAuthenticated (bool $state)

Set the authenticated status of this user.

Input
bool $state flag indicating the authenticated status of user
Output
void  

line 156

setAuthenticationHandler

public void setAuthenticationHandler ($handler)

Sets authentication handler.

Input
$handler
Output
void  

line 405

setAuthorizationHandler

public void setAuthorizationHandler ($handler)

Sets authorization handler.

Input
$handler
Output
void  

line 210

setExpiration

public void setExpiration (int $seconds, [bool $whenBrowserIsClosed = TRUE], [bool $clearIdentity = FALSE])

Enables sign out after inactivity.

Input
int $seconds number of seconds or timestamp
bool $whenBrowserIsClosed sign out when the browser is closed?
bool $clearIdentity clear the identity from persistent storage?
Output
void  

line 338

setIdentity

protected void setIdentity ([$identity = NULL])

Input
$identity
Output
void  

line 182

setNamespace

public void setNamespace (string $namespace)

Changes namespace; allows more users to share a session.

Implementation of:

Input
string $namespace
Output
void  

line 113

signOut

public void signOut ([bool $clearIdentity = FALSE])

Logs off the user from the current session.

Implementation of:

Input
bool $clearIdentity clear the identity from persistent storage?
Output
void