PHP Class Nette\Security\User

Inheritance: extends Nette\Object
Datei anzeigen Open project: nette/security Class Usage Examples

Public Properties

Property Type Description
$authenticatedRole default role for authenticated user without own identity
$guestRole default role for unauthenticated user
$onLoggedIn function (User $sender); Occurs when the user is successfully logged in
$onLoggedOut function (User $sender); Occurs when the user is logged out

Public Methods

Method Description
__construct ( Nette\Security\IUserStorage $storage, Nette\Security\IAuthenticator $authenticator = NULL, Nette\Security\IAuthorizator $authorizator = NULL )
getAuthenticator ( $need = TRUE ) : Nette\Security\IAuthenticator Returns authentication handler.
getAuthorizator ( $need = TRUE ) : Nette\Security\IAuthorizator Returns current authorization handler.
getId ( ) : mixed Returns current user ID, if any.
getIdentity ( ) : Nette\Security\IIdentity | null Returns current user identity, if any.
getLogoutReason ( ) : integer Why was user logged out?
getRoles ( ) : array Returns a list of effective roles that a user has been granted.
getStorage ( ) : Nette\Security\IUserStorage
isAllowed ( $resource = IAuthorizator::ALL, $privilege = IAuthorizator::ALL ) : boolean Has a user effective access to the Resource? If $resource is NULL, then the query applies to all resources.
isInRole ( $role ) : boolean Is a user in the specified effective role?
isLoggedIn ( ) : boolean Is this user authenticated?
login ( $id = NULL, $password = NULL ) : void Conducts the authentication process. Parameters are optional.
logout ( $clearIdentity = FALSE ) : void Logs out the user from the current session.
setAuthenticator ( Nette\Security\IAuthenticator $handler ) : self Sets authentication handler.
setAuthorizator ( Nette\Security\IAuthorizator $handler ) : self Sets authorization handler.
setExpiration ( $time, $whenBrowserIsClosed = TRUE, $clearIdentity = FALSE ) : self Enables log out after inactivity.

Method Details

__construct() public method

public __construct ( Nette\Security\IUserStorage $storage, Nette\Security\IAuthenticator $authenticator = NULL, Nette\Security\IAuthorizator $authorizator = NULL )
$storage Nette\Security\IUserStorage
$authenticator Nette\Security\IAuthenticator
$authorizator Nette\Security\IAuthorizator

getAuthenticator() public method

Returns authentication handler.
public getAuthenticator ( $need = TRUE ) : Nette\Security\IAuthenticator
return Nette\Security\IAuthenticator

getAuthorizator() public method

Returns current authorization handler.
public getAuthorizator ( $need = TRUE ) : Nette\Security\IAuthorizator
return Nette\Security\IAuthorizator

getId() public method

Returns current user ID, if any.
public getId ( ) : mixed
return mixed

getIdentity() public method

Returns current user identity, if any.
public getIdentity ( ) : Nette\Security\IIdentity | null
return Nette\Security\IIdentity | null

getLogoutReason() public method

Why was user logged out?
public getLogoutReason ( ) : integer
return integer

getRoles() public method

Returns a list of effective roles that a user has been granted.
public getRoles ( ) : array
return array

getStorage() public method

public getStorage ( ) : Nette\Security\IUserStorage
return Nette\Security\IUserStorage

isAllowed() public method

Has a user effective access to the Resource? If $resource is NULL, then the query applies to all resources.
public isAllowed ( $resource = IAuthorizator::ALL, $privilege = IAuthorizator::ALL ) : boolean
return boolean

isInRole() public method

Is a user in the specified effective role?
public isInRole ( $role ) : boolean
return boolean

isLoggedIn() public method

Is this user authenticated?
public isLoggedIn ( ) : boolean
return boolean

login() public method

Conducts the authentication process. Parameters are optional.
public login ( $id = NULL, $password = NULL ) : void
return void

logout() public method

Logs out the user from the current session.
public logout ( $clearIdentity = FALSE ) : void
return void

setAuthenticator() public method

Sets authentication handler.
public setAuthenticator ( Nette\Security\IAuthenticator $handler ) : self
$handler Nette\Security\IAuthenticator
return self

setAuthorizator() public method

Sets authorization handler.
public setAuthorizator ( Nette\Security\IAuthorizator $handler ) : self
$handler Nette\Security\IAuthorizator
return self

setExpiration() public method

Enables log out after inactivity.
public setExpiration ( $time, $whenBrowserIsClosed = TRUE, $clearIdentity = FALSE ) : self
return self

Property Details

$authenticatedRole public_oe property

default role for authenticated user without own identity
public $authenticatedRole

$guestRole public_oe property

default role for unauthenticated user
public $guestRole

$onLoggedIn public_oe property

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

$onLoggedOut public_oe property

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