PHP Class Tools\Model\Behavior\PasswordableBehavior

Also capable of: - Require current password prior to altering it (current=>true) - Don't allow the same password it was before (allowSame=>false) Usage: See docs
Inheritance: extends Cake\ORM\Behavior
Exibir arquivo Open project: dereuromark/cakephp-tools

Protected Properties

Property Type Description
$_defaultConfig array
$_passwordHasher Cake\Auth\AbstractPasswordHasher Password hasher instance.
$_validationRules array

Public Methods

Method Description
__construct ( Table $table, array $config = [] ) Adding validation rules also adds and merges config settings (direct + configure)
beforeMarshal ( Cake\Event\Event $event, ArrayObject $data, ArrayObject $options ) : void Preparing the data
beforeRules ( Cake\Event\Event $event, Cake\ORM\Entity $entity, ArrayObject $options, string $operation ) : void Preparing the data
beforeSave ( Cake\Event\Event $event, Cake\ORM\Entity $entity ) : void Hashing the password and whitelisting
initialize ( array $config ) : void Constructor hook method.
needsPasswordRehash ( string $hash ) : boolean Checks if the PasswordHasher class supports this and if so, whether the password needs to be rehashed or not.
validateCurrentPwd ( string $pwd, array $context ) : boolean If not implemented in Table class
validateIdentical ( string $value, array $options, array $context ) : boolean If not implemented in Table class
validateNotSame ( string $data, array $options, array $context ) : boolean If not implemented in Table class
validateNotSameHash ( string $data, array $context ) : boolean If not implemented in Table class

Protected Methods

Method Description
_getPasswordHasher ( string | array $hasher, array $options = [] ) : Cake\Auth\AbstractPasswordHasher PasswordableBehavior::_getPasswordHasher()
_validateSameHash ( string $pwd, array $context ) : boolean PasswordableBehavior::_validateSameHash()

Method Details

__construct() public method

Adding validation rules also adds and merges config settings (direct + configure)
public __construct ( Table $table, array $config = [] )
$table Cake\ORM\Table
$config array

_getPasswordHasher() protected method

PasswordableBehavior::_getPasswordHasher()
protected _getPasswordHasher ( string | array $hasher, array $options = [] ) : Cake\Auth\AbstractPasswordHasher
$hasher string | array Name or options array.
$options array
return Cake\Auth\AbstractPasswordHasher

_validateSameHash() protected method

PasswordableBehavior::_validateSameHash()
protected _validateSameHash ( string $pwd, array $context ) : boolean
$pwd string
$context array
return boolean Success

beforeMarshal() public method

Preparing the data
public beforeMarshal ( Cake\Event\Event $event, ArrayObject $data, ArrayObject $options ) : void
$event Cake\Event\Event
$data ArrayObject
$options ArrayObject
return void

beforeRules() public method

Preparing the data
public beforeRules ( Cake\Event\Event $event, Cake\ORM\Entity $entity, ArrayObject $options, string $operation ) : void
$event Cake\Event\Event
$entity Cake\ORM\Entity
$options ArrayObject
$operation string
return void

beforeSave() public method

Hashing the password and whitelisting
public beforeSave ( Cake\Event\Event $event, Cake\ORM\Entity $entity ) : void
$event Cake\Event\Event
$entity Cake\ORM\Entity
return void

initialize() public method

Implement this method to avoid having to overwrite the constructor and call parent.
public initialize ( array $config ) : void
$config array The configuration array this behavior is using.
return void

needsPasswordRehash() public method

This is mainly supported by Tools.Modern (using Bcrypt) yet.
public needsPasswordRehash ( string $hash ) : boolean
$hash string Currently hashed password.
return boolean Success

validateCurrentPwd() public method

Note: requires the used Auth component to be App::uses() loaded. It also reqires the same Auth setup as in your AppController's beforeFilter(). So if you set up any special passwordHasher or auth type, you need to provide those with the settings passed to the behavior: 'passwordHasher' => array( 'className' => 'Simple', 'hashType' => 'sha256' )
public validateCurrentPwd ( string $pwd, array $context ) : boolean
$pwd string
$context array
return boolean Success

validateIdentical() public method

If not implemented in Table class
public validateIdentical ( string $value, array $options, array $context ) : boolean
$value string
$options array
$context array
return boolean Success

validateNotSame() public method

If not implemented in Table class
public validateNotSame ( string $data, array $options, array $context ) : boolean
$data string
$options array
$context array
return boolean Success

validateNotSameHash() public method

If not implemented in Table class
public validateNotSameHash ( string $data, array $context ) : boolean
$data string
$context array
return boolean Success

Property Details

$_defaultConfig protected_oe property

protected array $_defaultConfig
return array

$_passwordHasher protected_oe property

Password hasher instance.
protected AbstractPasswordHasher,Cake\Auth $_passwordHasher
return Cake\Auth\AbstractPasswordHasher

$_validationRules protected_oe property

protected array $_validationRules
return array