I maintain a TYPO3 extension that manages frontend users in the backend. Therefore I extend the FrontendUserRepository with my own model. My extension provides CRUD operations and I have a problem with updating the password of existing persons. The idea is to only update the password, if the password field in the edit form is filled, otherwise (if it's left empty) the old password value remains in the database.
Now everything was working fine with TYPO3 4.5, but now after I upgraded to 6.2, an empty string is saved to the database when submitting the edit form with an empty password field...
This is my updateAction():
/**
* action update
*
* @param \My\Vendor\Domain\Model\Person $person
*
* @return void
*/
public function updateAction(\My\Vendor\Domain\Model\Person $person) {
// only hash and set password if not empty
if ($person->getPassword() == '') {
// if password was left empty, get current password from database
$oldPerson = $this->personRepository->findByUid($person->getUid());
$person->setPassword($oldPerson->getPassword()));
} else {
$person->setPassword(md5($person->getPassword()));
}
// save updated person to repository
$this->personRepository->update($person);
$this->flashMessageContainer->add('The person data was saved.');
$this->redirect('edit', NULL, NULL, array('person' => $person));
}
Does anybody know, why $oldPerson->getPassword() does not return the current value for the password field from the database? Or is there another way to "skip" a property of a domain model while updating all other properties? The strange thing is that it worked in TYPO3 4.5 ...