/**
* Determines whether the entity needs a new hash generated.
*
* @param AbstractData $data
* the CRUDlex data instance of the user entity
* @param Entity $entity
* the entity
* @param string $passwordField
* the field holding the password hash in the entity
* @param string $password
* the current password hash
* @param boolean $newSalt
* whether a new password hash salt was generated
*
* @return boolean
* true if the entity needs a new hash
*/
public function doGenerateHash(AbstractData $data, Entity $entity, $passwordField, $password, $newSalt)
{
$doGenerateHash = true;
$id = $entity->get('id');
if ($id !== null) {
$oldEntity = $data->get($entity->get('id'));
$doGenerateHash = $oldEntity->get($passwordField) !== $password || $newSalt;
}
return $doGenerateHash;
}