PHP Class YiiPassword\Behavior

Inheritance: extends CActiveRecordBehavior
Mostra file Open project: phpnode/yiipassword

Public Properties

Property Type Description
$autoUpgrade boolean If this is true, user passwords will be reencoded with the new strategy when they successfully authenticate with an old strategy.
$defaultStrategyName string The name of the default password strategy
$passwordAttribute string The name of the attribute that contains the encoded password
$requireNewPasswordAttribute string The name of the attribute that determines whether a user requires a new password or not
$saltAttribute string The name of the attribute that contains the password salt
$strategyAttribute string The name of the attribute that contains the password strategy name
$usernameAttribute string The name of the username attribute

Protected Properties

Property Type Description
$_strategies array
array(
 "hash" => array(
     "class" => "YiiPassword\Strategies\Hash",
     "hashMethod" => array("sha1"),
     "workFactor" => 50
 ),
 "md5" => array(
     "class" => "YiiPassword\Strategies\LegacyMd5"
 ),
)

Public Methods

Method Description
afterFind ( CModelEvent $event ) Invoked after the model is found, stores the hashed user password
beforeSave ( CModelEvent $event ) Invoked before the model is saved, re hashes the password if required
beforeValidate ( CModelEvent $event ) Invoked before the model is validated.
changePassword ( string $newPassword, boolean $runValidation = true ) : boolean Changes the user's password and saves the record
getDefaultStrategy ( ) : APasswordStrategy | boolean Gets the default password strategy
getPasswordResetCode ( ) : string Generates a password reset code to use for this user.
getStrategies ( ) : array Gets the password strategies
getStrategy ( ) : APasswordStrategy | boolean Gets the password strategy to use for this model
setStrategies ( Strategy[] | array $strategies ) Sets the strategies to use
verifyPassword ( string $password ) : boolean Compares the given password to the stored password for this model

Protected Methods

Method Description
changePasswordInternal ( string $password ) Changes the user's password but doesn't perform any saving

Method Details

afterFind() public method

Invoked after the model is found, stores the hashed user password
public afterFind ( CModelEvent $event )
$event CModelEvent the raised event

beforeSave() public method

Invoked before the model is saved, re hashes the password if required
public beforeSave ( CModelEvent $event )
$event CModelEvent the raised event

beforeValidate() public method

Validates the password first
public beforeValidate ( CModelEvent $event )
$event CModelEvent the raised event

changePassword() public method

Changes the user's password and saves the record
public changePassword ( string $newPassword, boolean $runValidation = true ) : boolean
$newPassword string the plain text password to change to
$runValidation boolean whether to run validation or not. If validate false, return false, and {UserModel} hasError(password).
return boolean true if the password was changed successfully

changePasswordInternal() protected method

Changes the user's password but doesn't perform any saving
protected changePasswordInternal ( string $password )
$password string the password to change to

getDefaultStrategy() public method

Gets the default password strategy
public getDefaultStrategy ( ) : APasswordStrategy | boolean
return APasswordStrategy | boolean the default password strategy, or false if none is configured

getPasswordResetCode() public method

This code can only be used once.
public getPasswordResetCode ( ) : string
return string the password reset code

getStrategies() public method

Gets the password strategies
public getStrategies ( ) : array
return array the password strategies

getStrategy() public method

Gets the password strategy to use for this model
public getStrategy ( ) : APasswordStrategy | boolean
return APasswordStrategy | boolean the password strategy, or false if none are configured

setStrategies() public method

Sets the strategies to use
public setStrategies ( Strategy[] | array $strategies )
$strategies Strategy[] | array the strategies to add

verifyPassword() public method

Compares the given password to the stored password for this model
public verifyPassword ( string $password ) : boolean
$password string the plain text password to check
return boolean true if the password matches, otherwise false

Property Details

$_strategies protected_oe property

array(
 "hash" => array(
     "class" => "YiiPassword\Strategies\Hash",
     "hashMethod" => array("sha1"),
     "workFactor" => 50
 ),
 "md5" => array(
     "class" => "YiiPassword\Strategies\LegacyMd5"
 ),
)
protected array $_strategies
return array

$autoUpgrade public_oe property

If this is true, user passwords will be reencoded with the new strategy when they successfully authenticate with an old strategy.
public bool $autoUpgrade
return boolean

$defaultStrategyName public_oe property

The name of the default password strategy
public string $defaultStrategyName
return string

$passwordAttribute public_oe property

The name of the attribute that contains the encoded password
public string $passwordAttribute
return string

$requireNewPasswordAttribute public_oe property

The name of the attribute that determines whether a user requires a new password or not
public string $requireNewPasswordAttribute
return string

$saltAttribute public_oe property

The name of the attribute that contains the password salt
public string $saltAttribute
return string

$strategyAttribute public_oe property

The name of the attribute that contains the password strategy name
public string $strategyAttribute
return string

$usernameAttribute public_oe property

The name of the username attribute
public string $usernameAttribute
return string