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
Afficher le fichier Open project: dereuromark/cakephp-tools

Protected Properties

Свойство Type Description
$_defaultConfig array
$_passwordHasher Cake\Auth\AbstractPasswordHasher Password hasher instance.
$_validationRules array

Méthodes publiques

Méthode 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

Méthodes protégées

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

Method Details

__construct() public méthode

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 méthode

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

_validateSameHash() protected méthode

PasswordableBehavior::_validateSameHash()
protected _validateSameHash ( string $pwd, array $context ) : boolean
$pwd string
$context array
Résultat boolean Success

beforeMarshal() public méthode

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

beforeRules() public méthode

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
Résultat void

beforeSave() public méthode

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

initialize() public méthode

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.
Résultat void

needsPasswordRehash() public méthode

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

validateCurrentPwd() public méthode

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
Résultat boolean Success

validateIdentical() public méthode

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

validateNotSame() public méthode

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

validateNotSameHash() public méthode

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

Property Details

$_defaultConfig protected_oe property

protected array $_defaultConfig
Résultat array

$_passwordHasher protected_oe property

Password hasher instance.
protected AbstractPasswordHasher,Cake\Auth $_passwordHasher
Résultat Cake\Auth\AbstractPasswordHasher

$_validationRules protected_oe property

protected array $_validationRules
Résultat array