Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationLatte
      • ApplicationTracy
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsLatte
      • Framework
      • HttpTracy
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Templating
    • Utils
  • NetteModule
  • none
  • Tracy

Classes

  • Identity
  • Passwords
  • Permission
  • SimpleAuthenticator
  • User

Interfaces

  • IAuthenticator
  • IAuthorizator
  • IIdentity
  • IResource
  • IRole
  • IUserStorage

Exceptions

  • AuthenticationException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage

Class User

User authentication and authorization.

Nette\Object
Extended by Nette\Security\User
Namespace: Nette\Security
Author: David Grudl
Located at Security/User.php
Methods summary
public
# __construct( Nette\Security\IUserStorage $storage, Nette\Security\IAuthenticator $authenticator = NULL, Nette\Security\IAuthorizator $authorizator = NULL )
public Nette\Security\IUserStorage
# getStorage( )

Returns

Nette\Security\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

Nette\Security\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 Nette\Security\IIdentity|null
# getIdentity( )

Returns current user identity, if any.

Returns current user identity, if any.

Returns

Nette\Security\IIdentity|null
public mixed
# getId( )

Returns current user ID, if any.

Returns current user ID, if any.

Returns

mixed
public Nette\Security\User
# setAuthenticator( Nette\Security\IAuthenticator $handler )

Sets authentication handler.

Sets authentication handler.

Returns

Nette\Security\User
public Nette\Security\IAuthenticator
# getAuthenticator( $need = TRUE )

Returns authentication handler.

Returns authentication handler.

Returns

Nette\Security\IAuthenticator
public Nette\Security\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

Nette\Security\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 = Nette\Security\IAuthorizator::ALL, string $privilege = Nette\Security\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 Nette\Security\User
# setAuthorizator( Nette\Security\IAuthorizator $handler )

Sets authorization handler.

Sets authorization handler.

Returns

Nette\Security\User
public Nette\Security\IAuthorizator
# getAuthorizator( $need = TRUE )

Returns current authorization handler.

Returns current authorization handler.

Returns

Nette\Security\IAuthorizator
Methods inherited from Nette\Object
__call(), __callStatic(), __get(), __isset(), __set(), __unset(), extensionMethod(), getReflection()
Constants summary
string MANUAL Nette\Security\IUserStorage::MANUAL
#

Deprecated

string INACTIVITY Nette\Security\IUserStorage::INACTIVITY
#

Deprecated

string BROWSER_CLOSED Nette\Security\IUserStorage::BROWSER_CLOSED
#

Deprecated

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 callable[] $onLoggedIn
#

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

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

public callable[] $onLoggedOut
#

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

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

Magic properties summary
public Nette\Security\IAuthenticator $authenticator
#
public Nette\Security\IAuthorizator $authorizator
#
public read-only boolean $loggedIn
#
public read-only Nette\Security\IIdentity $identity
#
public read-only mixed $id
#
public read-only array $roles
#
public read-only integer $logoutReason
#
public read-only Nette\Security\IUserStorage $storage
#
Magic properties inherited from Nette\Object
$reflection
Nette 2.2 API documentation generated by ApiGen 2.8.0