Class UserSetup
This class setups CRUDlex with some events so the passwords get salted and
hashed properly.
Namespace: CRUDlex
Located at UserSetup.php
Methods summary
protected
|
#
getPWHashFunction( CRUDlex\AbstractData $data, string $passwordField, string $saltField )
Gets a closure for possibly generating a password hash in the entity.
Gets a closure for possibly generating a password hash in the entity.
Parameters
- $data
- the AbstractData instance managing the users
- $passwordField
- the Entity fieldname of the password hash
- $saltField
- the Entity fieldname of the password hash salt
|
public
boolean
|
#
possibleGenSalt( string & $salt, CRUDlex\Entity $entity, string $saltField )
Generates a new salt if the given salt is null.
Generates a new salt if the given salt is null.
Parameters
- $salt
- the salt to override if null
- $entity
- entity getting the new salt
- $saltField
- the field holding the salt in the entity
Returns
boolean true if a new salt was generated
|
public
boolean
|
#
doGenerateHash( CRUDlex\AbstractData $data, CRUDlex\Entity $entity, string $passwordField, string $password, boolean $newSalt )
Determines whether the entity needs a new hash generated.
Determines whether the entity needs a new hash generated.
Parameters
- $data
- the CRUDlex data instance of the user entity
- $entity
- the entity
- $passwordField
- the field holding the password hash in the entity
- $password
- the current password hash
- $newSalt
- whether a new password hash salt was generated
Returns
boolean true if the entity needs a new hash
|
public
string
|
#
getSalt( integer $len )
Generates a random salt of the given length.
Generates a random salt of the given length.
Parameters
Returns
string a random salt of the given length
|
public
|
#
addEvents( CRUDlex\AbstractData $data, string $passwordField = 'password', string $saltField = 'salt' )
Setups CRUDlex with some events so the passwords get salted and
hashed properly.
Setups CRUDlex with some events so the passwords get salted and
hashed properly.
Parameters
- $data
- the AbstractData instance managing the users
- $passwordField
- the Entity fieldname of the password hash
- $saltField
- the Entity fieldname of the password hash salt
|