Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
      • Traits
    • Reflection
    • Security
    • Tokenizer
    • Utils
  • Tracy
    • Bridges
      • Nette
  • none

Classes

  • Identity
  • Passwords
  • Permission
  • SimpleAuthenticator
  • User

Interfaces

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

Exceptions

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

Class User

User authentication and authorization.

Nette\Security\User uses Nette\SmartObject
Namespace: Nette\Security
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
IUserStorage
public
# login( string|Nette\Security\IIdentity $user, string $password = null )

Conducts the authentication process. Parameters are optional.

Conducts the authentication process. Parameters are optional.

Parameters

$user
or Identity
$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
the identity from persistent storage?
public boolean
# isLoggedIn( )

Is this user authenticated?

Is this user authenticated?

Returns

boolean
bool
public Nette\Security\IIdentity|null
# getIdentity( )

Returns current user identity, if any.

Returns current user identity, if any.

Returns

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

Returns current user ID, if any.

Returns current user ID, if any.

Returns

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

Sets authentication handler.

Sets authentication handler.

Returns

Nette\Security\User
static
public Nette\Security\IAuthenticator|null
# getAuthenticator( $throw = true )

Returns authentication handler.

Returns authentication handler.

Returns

Nette\Security\IAuthenticator|null
IAuthenticator|null
public Nette\Security\User
# setExpiration( string|integer|DateTimeInterface $time, integer|boolean $flags = null, boolean $clearIdentity = false )

Enables log out after inactivity.

Enables log out after inactivity.

Parameters

$time
of seconds or timestamp
$flags
IUserStorage::CLEAR_IDENTITY
$clearIdentity
the identity from persistent storage? (deprecated)

Returns

Nette\Security\User
static
public integer|null
# getLogoutReason( )

Why was user logged out?

Why was user logged out?

Returns

integer|null
int|null
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
array
public boolean
# isInRole( string $role )

Is a user in the specified effective role?

Is a user in the specified effective role?

Parameters

$role

Returns

boolean
bool
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
resource
$privilege
privilege

Returns

boolean
bool
public Nette\Security\User
# setAuthorizator( Nette\Security\IAuthorizator $handler )

Sets authorization handler.

Sets authorization handler.

Returns

Nette\Security\User
static
public Nette\Security\IAuthorizator|null
# getAuthorizator( $throw = true )

Returns current authorization handler.

Returns current authorization handler.

Returns

Nette\Security\IAuthorizator|null
IAuthorizator|null
Methods used from Nette\SmartObject
__call(), __callStatic(), __get(), __isset(), __set(), __unset(), extensionMethod(), getReflection()
Constants summary
string MANUAL

Deprecated

#Nette\Security\IUserStorage::MANUAL
string INACTIVITY

Deprecated

#Nette\Security\IUserStorage::INACTIVITY
string BROWSER_CLOSED

Deprecated

#Nette\Security\IUserStorage::BROWSER_CLOSED
Properties summary
public string $guestRole

default role for unauthenticated user

default role for unauthenticated user

#'guest'
public string $authenticatedRole

default role for authenticated user without own identity

default role for authenticated user without own identity

#'authenticated'
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
Nette 2.4-20180918 API API documentation generated by ApiGen 2.8.0