Class NUser
NUser authentication and authorization.
public
void
|
#
login(
mixed
$username = NULL,
mixed
$password = NULL
)
Conducts the authentication process. Parameters are optional. Conducts the authentication process. Parameters are optional. Parameters$username mixed optional parameter (e.g. username)$password mixed optional parameter (e.g. password)Throws
NAuthenticationException if authentication was not successful
Implementation of |
final public
void
|
#
logout(
bool
$clearIdentity = false
)
Logs out the user from the current session. Logs out the user from the current session. Parameters$clearIdentity bool clear the identity from persistent storage?Implementation of |
final public
bool
|
#
isLoggedIn(
)
Is this user authenticated? |
final public
IIdentity
|
#
getIdentity(
)
Returns current user identity, if any. |
public
mixed
|
#
getId(
)
Returns current user ID, if any. Returns current user ID, if any. |
public
NUser
|
#
setAuthenticationHandler(
IAuthenticator
$handler
)
Sets authentication handler. Sets authentication handler. Parameters$handler IAuthenticatorReturnsNUser provides a fluent interface
Implementation of |
final public
IAuthenticator
|
#
getAuthenticationHandler(
)
Returns authentication handler. |
public
NUser
|
#
setNamespace(
string
$namespace
)
Changes namespace; allows more users to share a session. Changes namespace; allows more users to share a session. Parameters$namespace stringReturnsNUser provides a fluent interface
Implementation of |
final public
string
|
#
getNamespace(
)
Returns current namespace. |
public
NUser
|
#
setExpiration(
string|int|DateTime
$time,
bool
$whenBrowserIsClosed = true,
bool
$clearIdentity = false
)
Enables log out after inactivity. Enables log out after inactivity. Parameters$time string|int|DateTime number of seconds or timestamp$whenBrowserIsClosed bool log out when the browser is closed?$clearIdentity bool clear the identity from persistent storage?ReturnsNUser provides a fluent interface
|
final public
int
|
#
getLogoutReason(
)
Why was user logged out? Why was user logged out? |
protected
NSessionNamespace
|
#
getSessionNamespace(
$need
)
Returns and initializes $this->session. Returns and initializes $this->session. |
protected
NUser
|
#
setAuthenticated(
bool
$state
)
Sets the authenticated status of this user. Sets the authenticated status of this user. Parameters$state bool flag indicating the authenticated status of userReturnsNUser provides a fluent interface
|
protected
NUser
|
#
setIdentity(
IIdentity
$identity = NULL
)
Sets the user identity. Sets the user identity. Parameters$identity IIdentityReturnsNUser provides a fluent interface
|
public
array
|
#
getRoles(
)
Returns a list of effective roles that a user has been granted. |
final public
bool
|
#
isInRole(
string
$role
)
Is a user in the specified effective role? Is a user in the specified effective role? Parameters$role stringImplementation of |
public
bool
|
#
isAllowed(
string
$resource = NULL,
string
$privilege = NULL
)
Has a user effective access to the Resource? 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 privilegeImplementation of |
public
NUser
|
#
setAuthorizationHandler(
IAuthorizator
$handler
)
Sets authorization handler. Sets authorization handler. Parameters$handler IAuthorizatorReturnsNUser provides a fluent interface
Implementation of |
final public
IAuthorizator
|
#
getAuthorizationHandler(
)
Returns current authorization handler. |
protected
NSession
|
#
getSession(
)
Returns session handler. Returns session handler. |
Methods Inherited From NObject
getReflection(), __call(), __callStatic(), extensionMethod(), __get(), __set(), __isset(), __unset()
string
|
$guestRole | 'guest' |
default role for unauthenticated user # |
string
|
$authenticatedRole | 'authenticated' |
default role for authenticated user without own identity # |
array
|
$onLoggedIn | NULL |
of function(NUser $sender); Occurs when the user is successfully logged in # |
array
|
$onLoggedOut | NULL |
of function(NUser $sender); Occurs when the user is logged out # |