Skip to content

Commit

Permalink
[TASK] Clean up RemovePasswordIfEmptyMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeldesu committed Feb 7, 2024
1 parent 9bab978 commit ddfcd48
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions Classes/Middleware/RemovePasswordIfEmptyMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ class RemovePasswordIfEmptyMiddleware implements MiddlewareInterface
{
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
$typoscript = $configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT,
'femanager'
);
$requestBody = $request->getParsedBody();

if (!empty($typoscript['plugin.']['tx_femanager.']['settings.']['edit.']['misc.']['keepPasswordIfEmpty']) &&
empty($requestBody['tx_femanager_edit']['user']['password']) &&
empty($requestBody['tx_femanager_edit']['password_repeat'])) {
$requestBody = $request->getParsedBody();
unset($requestBody['tx_femanager_edit']['user']['password']);
unset($requestBody['tx_femanager_edit']['password_repeat']);
$request = $request->withParsedBody($requestBody);
if (isset($requestBody['tx_femanager_edit'])) {
$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
$typoscript = $configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT,
'femanager'
);

if (!empty($typoscript['plugin.']['tx_femanager.']['settings.']['edit.']['misc.']['keepPasswordIfEmpty']) &&
empty($requestBody['tx_femanager_edit']['user']['password']) &&
empty($requestBody['tx_femanager_edit']['password_repeat'])) {
unset($requestBody['tx_femanager_edit']['user']['password']);
unset($requestBody['tx_femanager_edit']['password_repeat']);
$request = $request->withParsedBody($requestBody);
}
}

return $handler->handle($request);
Expand Down

0 comments on commit ddfcd48

Please sign in to comment.