Packages

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • none

Classes

Interfaces

Exceptions

  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage

Class User

User authentication and authorization.

Object
Extended by User
Package: Nette\Security
Author: David Grudl
Located at Security/User.php
Methods summary
public
# __construct( IUserStorage $storage, DIContainer $context )
public IUserStorage
# getStorage( )

Returns

IUserStorage
public
# login( mixed $id = NULL, mixed $password = NULL )

Conducts the authentication process. Parameters are optional.

Conducts the authentication process. Parameters are optional.

Parameters

$id
mixed
optional parameter (e.g. username or IIdentity)
$password
mixed
optional parameter (e.g. password)

Throws

AuthenticationException
if authentication was not successful
public
# logout( boolean $clearIdentity = FALSE )

Logs out the user from the current session.

Logs out the user from the current session.

Parameters

$clearIdentity
boolean
clear the identity from persistent storage?
public boolean
# isLoggedIn( )

Is this user authenticated?

Is this user authenticated?

Returns

boolean
public IIdentity|null
# getIdentity( )

Returns current user identity, if any.

Returns current user identity, if any.

Returns

IIdentity|null
public mixed
# getId( )

Returns current user ID, if any.

Returns current user ID, if any.

Returns

mixed
public User
# setAuthenticator( IAuthenticator $handler )

Sets authentication handler.

Sets authentication handler.

Returns

User
public IAuthenticator
# getAuthenticator( )

Returns authentication handler.

Returns authentication handler.

Returns

IAuthenticator
public User
# setExpiration( string|integer|DateTime $time, boolean $whenBrowserIsClosed = TRUE, boolean $clearIdentity = FALSE )

Enables log out after inactivity.

Enables log out after inactivity.

Parameters

$time
string|integer|DateTime
number of seconds or timestamp
$whenBrowserIsClosed
boolean
log out when the browser is closed?
$clearIdentity
boolean
clear the identity from persistent storage?

Returns

User
public integer
# getLogoutReason( )

Why was user logged out?

Why was user logged out?

Returns

integer
public array
# getRoles( )

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

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

Returns

array
public boolean
# isInRole( string $role )

Is a user in the specified effective role?

Is a user in the specified effective role?

Parameters

$role
string

Returns

boolean
public boolean
# isAllowed( string $resource = IAuthorizator::ALL, string $privilege = IAuthorizator::ALL )

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

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

Parameters

$resource
string
resource
$privilege
string
privilege

Returns

boolean
public User
# setAuthorizator( IAuthorizator $handler )

Sets authorization handler.

Sets authorization handler.

Returns

User
public IAuthorizator
# getAuthorizator( )

Returns current authorization handler.

Returns current authorization handler.

Returns

IAuthorizator
public
# setNamespace( $namespace )

Deprecated

public
# getNamespace( )

Deprecated

public
# setAuthenticationHandler( $v )

Deprecated

public
# setAuthorizationHandler( $v )

Deprecated

Methods inherited from Object
__call(), __callStatic(), __get(), __isset(), __set(), __unset(), extensionMethod(), getReflection()
Properties summary
public string $guestRole 'guest'
#

default role for unauthenticated user

default role for unauthenticated user

public string $authenticatedRole 'authenticated'
#

default role for authenticated user without own identity

default role for authenticated user without own identity

public array $onLoggedIn
#

of function(User $sender); Occurs when the user is successfully logged in

of function(User $sender); Occurs when the user is successfully logged in

public array $onLoggedOut
#

of function(User $sender); Occurs when the user is logged out

of function(User $sender); Occurs when the user is logged out

Magic properties summary
public IAuthenticator $authenticator
#
public IAuthorizator $authorizator
#
public read-only boolean $loggedIn
#
public read-only IIdentity $identity
#
public read-only mixed $id
#
public read-only integer $logoutReason
#
public read-only array $roles
#
Magic properties inherited from Object
$reflection
Nette Framework 2.0.18 (for PHP 5.2, un-prefixed) API documentation generated by ApiGen 2.8.0