Class User (namespace Nette\Web)


User authentication and authorization.

Object
   |
   --User

Implements interfaces:

Copyright: Copyright (c) 2004, 2010 David Grudl
Located: in /Web/User.php (line 28)
Public Method Summary
User
void
authenticate ($username, $password, [$extra = NULL])
deprecated method - use login(), logout(), isLoggedIn()
IAuthenticator
Returns authentication handler.
IAuthorizator
Returns current authorization handler.
IIdentity
Returns current user identity, if any.
int
Why was user logged out?
string
Returns current namespace.
array
Returns a list of effective roles that a user has been granted.
void
deprecated method - use login(), logout(), isLoggedIn()
bool
isAllowed ([string $resource = NULL], [string $privilege = NULL])
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
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
Sets authentication handler.
User
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
Returns session handler.
protected SessionNamespace
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

__construct

public User __construct ()

Output
User  

line 437

authenticate

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

deprecated method - use login(), logout(), isLoggedIn()

Input
$username
$password
$extra

line 171

getAuthenticationHandler

public IAuthenticator getAuthenticationHandler ()

Returns authentication handler.

Output
IAuthenticator  

line 411

getAuthorizationHandler

public IAuthorizator getAuthorizationHandler ()

Returns current authorization handler.

Output
IAuthorizator  

line 146

getIdentity

public IIdentity getIdentity ()

Returns current user identity, if any.

Implementation of:

Output
IIdentity  

line 240

getLogoutReason

public int getLogoutReason ()

Why was user logged out?

Output
int  

line 201

getNamespace

public string getNamespace ()

Returns current namespace.

Implementation of:

Output
string  

line 347

getRoles

public array getRoles ()

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

Implementation of:

Output
array  

line 429

getSession

protected Session getSession ()

Returns session handler.

Output
Session  

line 252

getSessionNamespace

protected SessionNamespace getSessionNamespace ($need)

Returns and initializes $this->session.

Input
$need
Output
SessionNamespace  

line 452

getSignOutReason

public void getSignOutReason ()

deprecated method - use login(), logout(), isLoggedIn()

line 378

isAllowed

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

Has a user effective 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 447

isAuthenticated

public void isAuthenticated ()

deprecated method - use login(), logout(), isLoggedIn()

line 364

isInRole

public bool isInRole (string $role)

Is a user in the specified effective role?

Implementation of:

Input
string $role
Output
bool  

line 134

isLoggedIn

public bool isLoggedIn ()

Is this user authenticated?

Implementation of:

Output
bool  

line 89

login

public void login (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 116

logout

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

Logs out the user from the current session.

Implementation of:

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

line 305

setAuthenticated

protected User setAuthenticated (bool $state)

Sets the authenticated status of this user.

Input
bool $state flag indicating the authenticated status of user
Output
User provides a fluent interface

line 159

setAuthenticationHandler

public User setAuthenticationHandler ($handler)

Sets authentication handler.

Input
$handler
Output
User provides a fluent interface

line 399

setAuthorizationHandler

public User setAuthorizationHandler ($handler)

Sets authorization handler.

Input
$handler
Output
User provides a fluent interface

line 215

setExpiration

public User setExpiration (string|int|DateTime $time, [bool $whenBrowserIsClosed = TRUE], [bool $clearIdentity = FALSE])

Enables log out after inactivity.

Input
string|int|DateTime $time number of seconds or timestamp
bool $whenBrowserIsClosed log out when the browser is closed?
bool $clearIdentity clear the identity from persistent storage?
Output
User provides a fluent interface

line 331

setIdentity

protected User setIdentity ([$identity = NULL])

Sets the user identity.

Input
$identity
Output
User provides a fluent interface

line 186

setNamespace

public User setNamespace (string $namespace)

Changes namespace; allows more users to share a session.

Implementation of:

Input
string $namespace
Output
User provides a fluent interface

line 442

signOut

public void signOut ([$clearIdentity = FALSE])

deprecated method - use login(), logout(), isLoggedIn()

Input
$clearIdentity