Seems like I found a solution. Not sure if it's the best but so far it works. I realized, that processDatamap_preProcessFieldArray
is where the password is still available in plain text, so I need to use it to store the password (later it is already hashed, therefore unusable for me) using the registry.
The fieldArray values in processDatamap_afterDatabaseOperations
are only set, when a value was changed, so by checking if the password key was set, I know if the password was initially changed or not.
So this is what my solution looks like:
public function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $pObj) {
if ($table === "fe_users" && $status === "update" && isset($fieldArray['password'])) {
//get the password
$registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry');
$pw = $registry->get('be', 'lastPassword');
//do whatever is necessary with the plain text password...
//remove it
$registry->remove('be', 'lastPassword');
}
}
public function processDatamap_preProcessFieldArray(array &$fieldArray, $table, $id, \TYPO3\CMS\Core\DataHandling\DataHandler &$pObj) {
if ($table === "fe_users" && stripos($id, 'NEW') === false){
$pw = $fieldArray['password'];
$registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry');
$registry->set('be', 'lastPassword', $pw);
}
}