UserIdentity

Type
Class
Namespace
Craft
Inherits
Craft\UserIdentity » CUserIdentity » CBaseUserIdentity » CComponent
Implements
IUserIdentity
Since
1.0

UserIdentity represents the data needed to identify a user. It contains the authentication method that checks if the provided data can identity the user.

See also http://craftcms.com

View source

Public Properties

PropertyDescription
$errorCodeinteger – The authentication error code.
$errorMessagestring – The authentication error message.
$passwordstring – Password
$usernamestring – Username

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__construct()UserIdentity constructor.
__get()Returns a property value, an event handler list or a behavior based on its name.
__isset()Checks if a property value is null.
__set()Sets value of a component property.
__unset()Sets a component property to be null.
asa()Returns the named behavior object.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
attachEventHandler()Attaches an event handler to an event.
authenticate()Authenticates a user against the database.
canGetProperty()Determines whether a property can be read.
canSetProperty()Determines whether a property can be set.
clearState()Removes the specified state.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
detachEventHandler()Detaches an existing event handler.
disableBehavior()Disables an attached behavior.
disableBehaviors()Disables all behaviors attached to this component.
enableBehavior()Enables an attached behavior.
enableBehaviors()Enables all behaviors attached to this component.
evaluateExpression()Evaluates a PHP expression or callback under the context of this component.
getEventHandlers()Returns the list of attached event handlers for an event.
getId()
getIsAuthenticated()Returns a value indicating whether the identity is authenticated.
getName()Returns the display name for the identity (e.g. username).
getPersistentStates()Returns the identity states that should be persisted.
getState()Gets the persisted state by the specified name.
getUserModel()
hasEvent()Determines whether an event is defined.
hasEventHandler()Checks whether the named event has attached handlers.
hasProperty()Determines whether a property is defined.
logUserIn()
raiseEvent()Raises an event.
setPersistentStates()Sets an array of persistent states.
setState()Sets the named state with a given value.

__construct()

UserIdentity constructor.

View source

Arguments

  • $username (string) – Username
  • $password (string) – Password

Signature

public void __construct ( $username, $password )

authenticate()

Authenticates a user against the database.

View source

Returns

boolean – True, if authentication succeeds, false otherwise.

Signature

public boolean authenticate ( )

getId()

Signature

public integer getId ( )

getUserModel()

Signature

public Craft\UserModel getUserModel ( )

logUserIn()

View source

Arguments

  • $user

Returns

null

Signature

public null logUserIn ( $user )

Constants

ConstantDescription
ERROR_ACCOUNT_COOLDOWN
ERROR_ACCOUNT_LOCKED
ERROR_ACCOUNT_SUSPENDED
ERROR_NONE
ERROR_NO_CP_ACCESS
ERROR_NO_CP_OFFLINE_ACCESS
ERROR_NO_SITE_OFFLINE_ACCESS
ERROR_PASSWORD_INVALID
ERROR_PASSWORD_RESET_REQUIRED
ERROR_PENDING_VERIFICATION
ERROR_UNKNOWN_IDENTITY
ERROR_USERNAME_INVALID