From ddfcd48d60d45e0efe6f0f2cb41b0a7dc9698f0e Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Wed, 7 Feb 2024 13:34:14 +0100 Subject: [PATCH 01/11] [TASK] Clean up RemovePasswordIfEmptyMiddleware Related: https://projekte.in2code.de/issues/60045 --- .../RemovePasswordIfEmptyMiddleware.php | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Classes/Middleware/RemovePasswordIfEmptyMiddleware.php b/Classes/Middleware/RemovePasswordIfEmptyMiddleware.php index c4b2a07cff..a794a3ee84 100644 --- a/Classes/Middleware/RemovePasswordIfEmptyMiddleware.php +++ b/Classes/Middleware/RemovePasswordIfEmptyMiddleware.php @@ -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); From 0a0ffb172dd4f46bc52b52e574653e5b119fd8ae Mon Sep 17 00:00:00 2001 From: Stefan Busemann Date: Tue, 5 Nov 2024 21:40:05 +0100 Subject: [PATCH 02/11] [BUGFIX] changing image only resolves #535 --- Classes/Controller/EditController.php | 2 +- Classes/Utility/ObjectUtility.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Classes/Controller/EditController.php b/Classes/Controller/EditController.php index 9b9cf4e59d..fc82137b7b 100644 --- a/Classes/Controller/EditController.php +++ b/Classes/Controller/EditController.php @@ -220,7 +220,7 @@ public function deleteAction(User $user) */ protected function redirectIfNoChangesOnObject(User $user) { - if (!ObjectUtility::isDirtyObject($user)) { + if (!ObjectUtility::isDirtyObject($user, $this->request)) { $this->addFlashMessage(LocalizationUtility::translate('noChanges'), '', ContextualFeedbackSeverity::NOTICE); return $this->redirect('edit'); } diff --git a/Classes/Utility/ObjectUtility.php b/Classes/Utility/ObjectUtility.php index d583556e23..bed5e9ddce 100644 --- a/Classes/Utility/ObjectUtility.php +++ b/Classes/Utility/ObjectUtility.php @@ -7,6 +7,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Mvc\RequestInterface; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; use TYPO3\CMS\Extbase\Reflection\Exception\PropertyNotAccessibleException; use TYPO3\CMS\Extbase\Reflection\ObjectAccess; @@ -34,9 +35,10 @@ public static function getContentObject(): ContentObjectRenderer * Checks if object was changed or not * * @param object $object + * @param RequestInterface $request * @codeCoverageIgnore */ - public static function isDirtyObject($object): bool + public static function isDirtyObject($object, RequestInterface $request): bool { foreach (array_keys($object->_getProperties()) as $propertyName) { try { @@ -63,6 +65,15 @@ public static function isDirtyObject($object): bool return true; } } + + /** check if there is an uploaded image */ + $uploadedFiles = $request->getUploadedFiles(); + if ( + count($uploadedFiles) > 0 + && !empty($uploadedFiles['image']) + ) { + return true; + } } return false; } From f527a93def4fed5ad1554816fd761ce0d17eedd8 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Wed, 6 Nov 2024 13:28:28 +0100 Subject: [PATCH 03/11] [TASK] Change wording of "createRequestWaitingForAdminConfirm" localization string --- Resources/Private/Language/locallang.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index c41904f2b6..8499da1e9f 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -505,7 +505,7 @@ Thank you for your request. Please check your mail account to confirm the profile. - Thank you for your confirmation. Your profile will be available as soon as the admin confirms your request. + Thank you for your registration. Your profile will be available as soon as the admin confirms your request. An Email was send to your account. Please check your inbox. From 91ef14028d5048547c7c24ac97579ca8991a29c0 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Wed, 6 Nov 2024 19:09:05 +0100 Subject: [PATCH 04/11] [TASK] Add max size validations for default fe_user fields --- .../TypoScript/Main/setup.typoscript | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/Configuration/TypoScript/Main/setup.typoscript b/Configuration/TypoScript/Main/setup.typoscript index c0a470af15..0a38ccd44c 100644 --- a/Configuration/TypoScript/Main/setup.typoscript +++ b/Configuration/TypoScript/Main/setup.typoscript @@ -126,6 +126,7 @@ plugin.tx_femanager { required = 1 uniqueInDb = 1 mustNotInclude = space + max = 255 } email { required = 1 @@ -156,6 +157,39 @@ plugin.tx_femanager { required = 0 if = In2code\Femanager\Domain\Validator\ShouldValidateStateCondition } + name { + max = 160 + } + first_name { + max = 50 + } + middle_name { + max = 50 + } + last_name { + max = 50 + } + telephone { + max = 30 + } + fax { + max = 30 + } + title { + max = 40 + } + zip { + max = 10 + } + city { + max = 50 + } + country { + max = 40 + } + www { + max = 80 + } } # All email settings within the creation process @@ -743,6 +777,39 @@ plugin.tx_femanager { # requires installation of sr_freecap # captcha = 1 } + name { + max = 160 + } + first_name { + max = 50 + } + middle_name { + max = 50 + } + last_name { + max = 50 + } + telephone { + max = 30 + } + fax { + max = 30 + } + title { + max = 40 + } + zip { + max = 10 + } + city { + max = 50 + } + country { + max = 40 + } + www { + max = 80 + } } # All email settings within the update process email { From d01effe298fb75aad01ec38aeee6a4055e14805b Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Thu, 7 Nov 2024 16:42:25 +0100 Subject: [PATCH 05/11] [TASK] Fix PHP CS Fixer lints --- Classes/Controller/UserBackendController.php | 6 +++--- Classes/Controller/UserController.php | 1 - Classes/Domain/Validator/AbstractValidator.php | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Classes/Controller/UserBackendController.php b/Classes/Controller/UserBackendController.php index 8d9f9bbfbf..3c3545e350 100644 --- a/Classes/Controller/UserBackendController.php +++ b/Classes/Controller/UserBackendController.php @@ -154,9 +154,9 @@ private function checkPageAndUserAccess($user): bool $pageRepository = GeneralUtility::makeInstance(PageRepository::class); $pageRow = $pageRepository->getPage($user->getPid()); if ($GLOBALS['BE_USER']->doesUserHaveAccess( - $pageRow, - Permission::PAGE_SHOW - ) === false) { + $pageRow, + Permission::PAGE_SHOW + ) === false) { return false; } } diff --git a/Classes/Controller/UserController.php b/Classes/Controller/UserController.php index 99746dcdbf..e3818aea6d 100644 --- a/Classes/Controller/UserController.php +++ b/Classes/Controller/UserController.php @@ -15,7 +15,6 @@ use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Error\Http\UnauthorizedException; use TYPO3\CMS\Core\Http\RedirectResponse; -use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; diff --git a/Classes/Domain/Validator/AbstractValidator.php b/Classes/Domain/Validator/AbstractValidator.php index 592c96b3ca..1acec1f0f6 100644 --- a/Classes/Domain/Validator/AbstractValidator.php +++ b/Classes/Domain/Validator/AbstractValidator.php @@ -16,7 +16,6 @@ use TYPO3\CMS\Core\Http\ApplicationType; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; -use TYPO3\CMS\Extbase\Utility\DebuggerUtility; use TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator as AbstractValidatorExtbase; /** @@ -120,8 +119,7 @@ protected function validateFileRequired(mixed $value, string $fieldName): bool if (isset($uploadedFiles[$this->pluginService->getFemanagerPluginNameFromRequest()][$fieldName])) { return true; } - } - else { + } else { return $this->validateRequired($value); } return false; From 218917a80d928efe0009062fe8c97fa286ddc408 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Thu, 7 Nov 2024 16:43:03 +0100 Subject: [PATCH 06/11] [TASK] Run Rector inside of DDEV PHPStan is installed via Phive and if there is some kind of dependency here, that is resolved inside DDEV but not in a regular install --- .github/workflows/testing.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index 0c3b61cccb..2b9b815608 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -62,10 +62,13 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: 8.1 + - uses: ddev/github-action-setup-ddev@v1 - name: "Composer Install" - run: "composer install" - - name: "Run PHP Rector" - run: "composer test:rector" + run: "ddev composer install" + - name: "Initialize TYPO3 in ddev" + run: "ddev initialize" + - name: "Run Behat Tests" + run: "ddev composer test:rector" unit-tests: name: "PHP Unit Tests" runs-on: ubuntu-20.04 From db50d297f58a9e4b7404141f825fd2020da611b5 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Thu, 7 Nov 2024 17:13:36 +0100 Subject: [PATCH 07/11] [BUGFIX] Fix documentation rendering --- Documentation/Features/ShowListUsers/Index.rst | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Documentation/Features/ShowListUsers/Index.rst b/Documentation/Features/ShowListUsers/Index.rst index aee8b8d721..0e678f86ed 100644 --- a/Documentation/Features/ShowListUsers/Index.rst +++ b/Documentation/Features/ShowListUsers/Index.rst @@ -21,14 +21,22 @@ Useful, if you want to show a "read only view" for the currently logged in front #. Add a femanager_detail plugin to your page #. in the field "User to show" choose "Logged in FE User" -|showlistusers1| +.. image:: ../../Images/feature-showlistusers-loggedin-user.png + :align: left + :border: 0 + :name: create1 + :vspace: 20 Show a given user ^^^^^^^^^^^^^^^^^ You can provide a detail view of a given frontend user -|showlistusers2| +.. image:: ../../Images/feature-showlistusers-loggedin-user1.png + :align: left + :border: 0 + :name: create1 + :vspace: 20 #. Add a femanager_detail plugin to your page #. select the user to be shown in the field "User to show" @@ -47,7 +55,11 @@ List Users #. set the plugin options to show the users you want to display -|showlistusers3| +.. image:: ../../Images/feature-showlistusers-loggedin-user2.png + :align: left + :border: 0 + :name: create1 + :vspace: 20 Plugin Options: From 2e7d918fbda9303be146990df4e7afe264ef6272 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Fri, 8 Nov 2024 12:37:36 +0100 Subject: [PATCH 08/11] [BUGFIX] Use configured receiver name in createAdminNotify --- Classes/Controller/AbstractController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index 83aecbbd0d..6d134dab1b 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -367,7 +367,8 @@ public function finalCreate( $this->sendMailService->send( 'createNotify', StringUtility::makeEmailArray( - $createAdminNotify + $createAdminNotify, + ConfigurationUtility::getValue('new./email./createAdminNotify./receiver./name./value', $this->config) ?? 'femanager' ), StringUtility::makeEmailArray($user->getEmail(), $user->getUsername()), $this->contentObject->cObjGetSingle( From 1c10e9cb50a21e6f85f1e66638be362e687fc475 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Fri, 8 Nov 2024 13:56:27 +0100 Subject: [PATCH 09/11] [BUGFIX] Fix configuration fetching for admin edit notify mails --- Classes/Controller/AbstractController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index 83aecbbd0d..489e0bf4ce 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -239,9 +239,9 @@ public function updateAllConfirmed(User $user) 'updateNotify', StringUtility::makeEmailArray( ConfigurationUtility::getValue( - 'edit/email/createUserNotify/notifyAdmin/receiver/email/value', + 'edit./email./notifyAdmin./receiver./email./value', $this->config - ) ?: ConfigurationUtility::getValue('edit/notifyAdmin', $this->config), + ) ?: ConfigurationUtility::getValue('edit./notifyAdmin', $this->config), $this->settings['edit']['email']['notifyAdmin']['receiver']['name']['value'] ?? null ), StringUtility::makeEmailArray($user->getEmail(), $user->getUsername()), From 31713b63e22353efd702d5d2ce2d3192339cc7b6 Mon Sep 17 00:00:00 2001 From: Stefan Busemann Date: Mon, 11 Nov 2024 12:59:07 +0100 Subject: [PATCH 10/11] [BUGFIX] Missing configuration check --- Classes/Utility/ConfigurationUtility.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Utility/ConfigurationUtility.php b/Classes/Utility/ConfigurationUtility.php index 48f48f1050..173f864380 100644 --- a/Classes/Utility/ConfigurationUtility.php +++ b/Classes/Utility/ConfigurationUtility.php @@ -192,10 +192,10 @@ public static function getValue($key, $config) public static function notifyAdminAboutEdits($config) { if (self::getValue( - 'edit/notifyAdmin', + 'edit/email/notifyAdmin', $config ) || self::getValue( - 'edit/email/createUserNotify/notifyAdmin/receiver/email/value', + 'edit/email/notifyAdmin/receiver/email/value', $config )) { return true; From 370b0a0eb2261b5c43662c871c824f415c08df2b Mon Sep 17 00:00:00 2001 From: Stefan Busemann Date: Mon, 11 Nov 2024 13:03:18 +0100 Subject: [PATCH 11/11] [DOCS] Add Feature info and test case link --- .FemanagerFeaturesList.md | 65 ++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/.FemanagerFeaturesList.md b/.FemanagerFeaturesList.md index 5235c8ebd7..05c51754c1 100644 --- a/.FemanagerFeaturesList.md +++ b/.FemanagerFeaturesList.md @@ -3,41 +3,42 @@ ## Funktionen ### Frontend-User Registration -| Feature | State in TYPO3v12 | -|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------| -| One step registration with autologin | not working | -| Main configuration with Flexform | working | -| User confirmation (Double-Opt In) (optional) | working | -| Administration confirmation (optional) | working | -| Refuse and Silent Refuse | working | -| Fill email field with username (optional) | working | -| Redirect with TypoScript standardWrap (optional) | working | -| Prefill Formfields via TypoScript standardWrap (optional) | working | -| Multiple Validation Possibilities (JavaScript and PHP) (required, email, min, max, intOnly, lettersOnly, unicodeLettersOnly, uniqueInPage, uniqueInDb, mustInclude(number,letter,special), inList(1,2,3)) | working | -| Same PHP Methods for JavaScript and PHP Validation | working | -| Simply extend validation methods with your extension | working | -| Override a lot of Email settings with TypoScript if needed | working | -| Set mail attachments or embeded images | working | -| Override field values on every single step (e.g. push user to usergroup1 and if he is ready confimed push him to usergroup2) | working | -| Send user values to a third party software (e.g. a CRM like salesforce) | working | -| Store values in other database tables (e.g. tt_address) | working | -| Add Captcha (sr_freecap) for spam prevention | cannot be tested at the moment | +| Feature | State in TYPO3v12 | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------| +| One step registration with autologin | working | +| Main configuration with Flexform | working | +| User confirmation (Double-Opt In) (optional) | working | +| Administration confirmation (optional) | working | +| Refuse and Silent Refuse | working | +| Fill email field with username (optional) | working | +| Redirect with TypoScript standardWrap (optional) | working | +| Prefill Formfields via TypoScript standardWrap (optional) | working | +| Multiple Validation Possibilities (JavaScript and PHP) (required, email, min, max, intOnly, lettersOnly, unicodeLettersOnly, uniqueInPage, uniqueInDb, mustInclude(number,letter,special), inList(1,2,3)) | working | +| Same PHP Methods for JavaScript and PHP Validation | working | +| Simply extend validation methods with your extension | working | +| Override a lot of Email settings with TypoScript if needed | working | +| Set mail attachments or embeded images | working | +| Override field values on every single step (e.g. push user to usergroup1 and if he is ready confimed push him to usergroup2) | working | +| Send user values to a third party software (e.g. a CRM like salesforce) | working | +| Store values in other database tables (e.g. tt_address) | working | +| Add Captcha (sr_freecap) for spam prevention | not tested | ### Edit Profile -| Feature | State in TYPO3v12 | -|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------| -| Main configuration with Flexform | worming | -| Administration confirmation for change request (optional) | working | -| Refuse and Silent Refuse | working | -| Fill email field with username (optional) | working | -| Prefill Formfields via TypoScript standardWrap (optional) | working | -| Multiple Validation Possibilities (JavaScript and PHP) (required, email, min, max, intOnly, lettersOnly, unicodeLettersOnly, uniqueInPage, uniqueInDb, mustInclude(number,letter,special), inList(1,2,3)) | working | -| Same PHP Methods for JavaScript and PHP Validation | working | -| Simply extend validation methods with your extension | working | -| Override a lot of Email settings with TypoScript if needed | working | -| Set mail attachments or embeded images | working | -| Delete profile with TypoScript redirect | working | +| Feature | State in TYPO3v12 | Testcase URL | +|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|------------------------------------------------------| +| Main configuration with Flexform | worming | | +| Administration confirmation for change request (optional) | working | | +| Refuse and Silent Refuse | working | | +| Fill email field with username (optional) | working | | +| Prefill Formfields via TypoScript standardWrap (optional) | working | | +| Multiple Validation Possibilities (JavaScript and PHP) (required, email, min, max, intOnly, lettersOnly, unicodeLettersOnly, uniqueInPage, uniqueInDb, mustInclude(number,letter,special), inList(1,2,3)) | working | | +| Same PHP Methods for JavaScript and PHP Validation | working | | +| Simply extend validation methods with your extension | working | | +| Override a lot of Email settings with TypoScript if needed | working | | +| Set mail attachments or embeded images | working | | +| Delete profile with TypoScript redirect | working | | +| Notify Admin on changes | working | https://femanager8.ddev.site/edit/small/admin-notify | ### Invitation