From e48d24facd3605947ee2eee7dbc89cb116bf5ed6 Mon Sep 17 00:00:00 2001 From: DACHCOM Bot Date: Wed, 18 Dec 2024 18:16:21 +0000 Subject: [PATCH] [CS] Refactor --- src/Adapter/Group/AbstractGroup.php | 11 +++++++ src/Adapter/Group/GroupInterface.php | 11 +++++++ src/Adapter/Group/GroupTrait.php | 11 +++++++ src/Adapter/Sso/AbstractSSoIdentity.php | 11 +++++++ src/Adapter/Sso/SsoIdentityInterface.php | 11 +++++++ src/Adapter/User/AbstractCustomerUser.php | 11 +++++++ src/Adapter/User/AbstractSsoAwareUser.php | 11 +++++++ src/Adapter/User/AbstractUser.php | 11 +++++++ src/Adapter/User/SsoAwareUserInterface.php | 11 +++++++ src/Adapter/User/UserInterface.php | 11 +++++++ src/Adapter/User/UserTrait.php | 13 +++++++- src/Command/ClassInstallerCommand.php | 12 ++++++- src/Command/OAuthSetupCommand.php | 12 ++++++- src/Configuration/Configuration.php | 11 +++++++ src/Controller/AbstractController.php | 11 +++++++ .../Admin/RestrictionController.php | 13 +++++++- src/Controller/AuthController.php | 11 +++++++ src/Controller/ChangePasswordController.php | 13 +++++++- src/Controller/DeleteAccountController.php | 13 +++++++- src/Controller/EmailController.php | 13 +++++++- src/Controller/OAuthController.php | 15 +++++++-- src/Controller/ProfileController.php | 13 +++++++- src/Controller/RegistrationController.php | 21 ++++++++++--- src/Controller/RequestController.php | 16 ++++++++-- src/Controller/ResettingController.php | 13 +++++++- src/CoreExtension/GroupMultiselect.php | 25 +++++++++------ .../Provider/RoleOptionsProvider.php | 14 +++++++-- .../CompilerPass/OAuthLoginStrategyPass.php | 11 +++++++ src/DependencyInjection/Configuration.php | 17 +++++++--- src/DependencyInjection/MembersExtension.php | 17 ++++++++-- .../Areabrick/MembersLogin/MembersLogin.php | 31 +++++++++++++------ src/Document/Builder/BrickBuilder.php | 12 ++++++- src/Event/FilterUserResponseEvent.php | 11 +++++++ src/Event/FormEvent.php | 13 +++++++- src/Event/GetResponseNullableUserEvent.php | 11 +++++++ src/Event/GetResponseUserEvent.php | 11 +++++++ src/Event/OAuth/OAuthIdentityEvent.php | 11 +++++++ src/Event/OAuth/OAuthResourceEvent.php | 11 +++++++ src/Event/OAuth/OAuthResourceRefreshEvent.php | 11 +++++++ src/Event/OAuth/OAuthResponseEvent.php | 11 +++++++ src/Event/RestrictionEvent.php | 11 +++++++ src/Event/StaticRouteEvent.php | 11 +++++++ src/Event/UserEvent.php | 15 +++++++-- src/EventListener/Admin/AssetListener.php | 11 +++++++ .../AssetFrontendPathListener.php | 11 +++++++ src/EventListener/AuthenticationListener.php | 15 +++++++-- src/EventListener/FlashListener.php | 15 +++++++-- src/EventListener/ForbiddenRouteListener.php | 13 +++++++- .../Frontend/HeadMetaListener.php | 11 +++++++ src/EventListener/LastLoginListener.php | 11 +++++++ .../SsoCleanUpExpiredTokenListener.php | 17 ++++++++-- .../MembersCompletenessListener.php | 13 +++++++- .../OAuthRegistrationListener.php | 11 +++++++ .../PostConfirmationListener.php | 11 +++++++ src/EventListener/ResettingListener.php | 11 +++++++ .../RestrictionStoreListener.php | 17 ++++++++-- src/EventListener/TreeListener.php | 12 ++++++- src/EventListener/UserChangeListener.php | 11 +++++++ src/Exception/EntityNotRefreshedException.php | 11 +++++++ ...egistrationAuthIdentifierTypeExtension.php | 11 +++++++ .../Extension/RegistrationTypeExtension.php | 11 +++++++ src/Form/Factory/FactoryInterface.php | 11 +++++++ src/Form/Factory/FormFactory.php | 14 +++++++-- src/Form/Type/ChangePasswordFormType.php | 11 +++++++ src/Form/Type/DeleteAccountFormType.php | 11 +++++++ src/Form/Type/LoginFormType.php | 11 +++++++ src/Form/Type/ProfileFormType.php | 11 +++++++ src/Form/Type/RegistrationFormType.php | 11 +++++++ src/Form/Type/ResettingFormType.php | 11 +++++++ src/Form/Type/ResettingRequestFormType.php | 11 +++++++ src/Form/Type/Sso/CompleteProfileFormType.php | 11 +++++++ src/Mailer/Mailer.php | 14 +++++++-- src/Mailer/MailerInterface.php | 11 +++++++ src/Manager/ClassManager.php | 12 ++++++- src/Manager/ClassManagerInterface.php | 11 +++++++ src/Manager/LoginManager.php | 11 +++++++ src/Manager/LoginManagerInterface.php | 11 +++++++ src/Manager/RestrictionManager.php | 18 ++++++++--- src/Manager/RestrictionManagerInterface.php | 11 +++++++ src/Manager/SsoIdentityManager.php | 15 +++++++-- src/Manager/SsoIdentityManagerInterface.php | 11 +++++++ src/Manager/UserManager.php | 12 ++++++- src/Manager/UserManagerInterface.php | 11 +++++++ src/MembersBundle.php | 13 +++++++- src/MembersEvents.php | 17 ++++++++-- src/Registry/OAuthLoginProcessorRegistry.php | 11 +++++++ .../OAuthLoginProcessorRegistryInterface.php | 11 +++++++ src/Restriction/Dao.php | 14 ++++++++- src/Restriction/ElementRestriction.php | 11 +++++++ src/Restriction/Restriction.php | 15 +++++++-- .../OAuthIdentityAuthenticator.php | 12 ++++++- src/Security/OAuth/AccountConnector.php | 11 +++++++ .../OAuth/AccountConnectorInterface.php | 11 +++++++ .../OAuth/Dispatcher/ConnectDispatcher.php | 19 +++++++++--- .../OAuth/Dispatcher/DispatcherInterface.php | 11 +++++++ .../OAuth/Dispatcher/LoginDispatcher.php | 13 +++++++- .../CompleteProfileProcessor.php | 15 +++++++-- .../LoginProcessor/InstantProcessor.php | 11 +++++++ .../LoginProcessorInterface.php | 11 +++++++ .../Dispatcher/Router/DispatchRouter.php | 11 +++++++ .../Exception/AccountNotLinkedException.php | 11 +++++++ .../OAuth/OAuthRegistrationHandler.php | 11 +++++++ src/Security/OAuth/OAuthResponse.php | 11 +++++++ src/Security/OAuth/OAuthResponseInterface.php | 11 +++++++ src/Security/OAuth/OAuthScopeAllocator.php | 11 +++++++ .../OAuth/OAuthScopeAllocatorInterface.php | 11 +++++++ src/Security/OAuth/OAuthTokenStorage.php | 11 +++++++ .../OAuth/OAuthTokenStorageInterface.php | 11 +++++++ src/Security/RestrictionQuery.php | 23 ++++++++++++-- src/Security/RestrictionUri.php | 17 ++++++++-- src/Security/UserChecker.php | 11 +++++++ src/Security/UserProvider.php | 11 +++++++ ...questPropertiesForUserExtractorService.php | 13 +++++++- ...ertiesForUserExtractorServiceInterface.php | 11 +++++++ src/Service/ResourceMappingService.php | 14 +++++++-- src/Service/RestrictionService.php | 17 +++++++--- src/Service/SsoIdentityStatusService.php | 17 ++++++++-- .../SsoIdentityStatusServiceInterface.php | 11 +++++++ src/Session/SessionConfigurator.php | 11 +++++++ src/Tool/ClassInstaller.php | 14 +++++++-- src/Tool/Install.php | 13 +++++++- src/Tool/TokenGenerator.php | 11 +++++++ src/Tool/TokenGeneratorInterface.php | 11 +++++++ src/Twig/Extension/NavigationExtension.php | 12 ++++++- src/Twig/Extension/OAuthExtension.php | 13 +++++++- .../Extension/RestrictionUriExtension.php | 13 +++++++- src/Twig/Extension/SystemExtension.php | 13 +++++++- .../RegistrationValidationGroupResolver.php | 11 +++++++ .../ValidationGroupResolverInterface.php | 13 +++++++- .../Constraints/PimcoreUniqueEntity.php | 11 +++++++ .../PimcoreUniqueEntityValidator.php | 11 +++++++ 131 files changed, 1540 insertions(+), 115 deletions(-) diff --git a/src/Adapter/Group/AbstractGroup.php b/src/Adapter/Group/AbstractGroup.php index fd6f9320..7adc35aa 100644 --- a/src/Adapter/Group/AbstractGroup.php +++ b/src/Adapter/Group/AbstractGroup.php @@ -1,5 +1,16 @@ getId() === $this->getId(); + return $user instanceof self && $user->getId() === $this->getId(); } public function getRoles(): array diff --git a/src/Command/ClassInstallerCommand.php b/src/Command/ClassInstallerCommand.php index d121c5d6..0ce7c120 100644 --- a/src/Command/ClassInstallerCommand.php +++ b/src/Command/ClassInstallerCommand.php @@ -1,5 +1,16 @@ renderTemplate('@Members/email/email.html.twig', array_filter($request->attributes->all(), static function($parameterKey) { + return $this->renderTemplate('@Members/email/email.html.twig', array_filter($request->attributes->all(), static function ($parameterKey) { return !str_starts_with($parameterKey, '_'); }, ARRAY_FILTER_USE_KEY)); } diff --git a/src/Controller/OAuthController.php b/src/Controller/OAuthController.php index 30ec8bbe..64d92da5 100644 --- a/src/Controller/OAuthController.php +++ b/src/Controller/OAuthController.php @@ -1,5 +1,16 @@ ['key' => $role, 'value' => $role], + static fn ($role): array => ['key' => $role, 'value' => $role], array_unique($roles) ); } diff --git a/src/DependencyInjection/CompilerPass/OAuthLoginStrategyPass.php b/src/DependencyInjection/CompilerPass/OAuthLoginStrategyPass.php index 557ed6b1..0a7bc6ae 100644 --- a/src/DependencyInjection/CompilerPass/OAuthLoginStrategyPass.php +++ b/src/DependencyInjection/CompilerPass/OAuthLoginStrategyPass.php @@ -1,5 +1,16 @@ getExtensionConfig($this->getAlias()); $config = $this->processConfiguration($this->getConfiguration([], $container), $configs); - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ if (!$container->hasParameter('members.firewall_name')) { $container->setParameter('members.firewall_name', 'members_fe'); } diff --git a/src/Document/Areabrick/MembersLogin/MembersLogin.php b/src/Document/Areabrick/MembersLogin/MembersLogin.php index c230fe61..2776ca87 100644 --- a/src/Document/Areabrick/MembersLogin/MembersLogin.php +++ b/src/Document/Areabrick/MembersLogin/MembersLogin.php @@ -1,5 +1,16 @@ setItems([ [ - 'type' => 'relation', - 'label' => $this->translator->trans('redirect after successful login', [], 'admin'), - 'name' => 'redirectAfterSuccess', + 'type' => 'relation', + 'label' => $this->translator->trans('redirect after successful login', [], 'admin'), + 'name' => 'redirectAfterSuccess', 'config' => [ - 'types' => ['document'], + 'types' => ['document'], 'subtypes' => [ 'document' => ['page', 'link', 'hardlink'] ] ] ], [ - 'type' => 'checkbox', + 'type' => 'checkbox', 'label' => $this->translator->trans('Hide when logged in', [], 'admin'), - 'name' => 'hideWhenLoggedIn', + 'name' => 'hideWhenLoggedIn', ], [ - 'type' => 'relation', - 'label' => $this->translator->trans('Show this snippet when logged in', [], 'admin'), - 'name' => 'showSnippedWhenLoggedIn', + 'type' => 'relation', + 'label' => $this->translator->trans('Show this snippet when logged in', [], 'admin'), + 'name' => 'showSnippedWhenLoggedIn', 'config' => [ - 'types' => ['document'], + 'types' => ['document'], 'subtypes' => [ 'document' => ['snippet'] ] diff --git a/src/Document/Builder/BrickBuilder.php b/src/Document/Builder/BrickBuilder.php index 8c7e9ca3..2c81c87b 100644 --- a/src/Document/Builder/BrickBuilder.php +++ b/src/Document/Builder/BrickBuilder.php @@ -1,5 +1,16 @@ 'auth/area/login_area', 'area-logged-in' => 'auth/area/login_area_logged_in', diff --git a/src/Event/FilterUserResponseEvent.php b/src/Event/FilterUserResponseEvent.php index 327e03b1..5dd418ae 100755 --- a/src/Event/FilterUserResponseEvent.php +++ b/src/Event/FilterUserResponseEvent.php @@ -1,5 +1,16 @@ getArgument('assets'); foreach ($assets as &$asset) { - if (!isset($asset['basePath'])) { continue; } diff --git a/src/EventListener/UserChangeListener.php b/src/EventListener/UserChangeListener.php index 9fc534e9..99c63fdb 100644 --- a/src/EventListener/UserChangeListener.php +++ b/src/EventListener/UserChangeListener.php @@ -1,5 +1,16 @@ setSection($this->isFrontendRequestByAdmin() || !$this->elementIsInProtectedStorageFolder($element) + $elementRestriction->setSection( + $this->isFrontendRequestByAdmin() || !$this->elementIsInProtectedStorageFolder($element) ? self::RESTRICTION_SECTION_ALLOWED : self::RESTRICTION_SECTION_NOT_ALLOWED ); @@ -91,7 +102,6 @@ public function getElementRestrictionStatus(ElementInterface $element): ElementR } return $elementRestriction->setSection($this->filterAllowedSectionToUser($user->getGroups(), $restriction->getRelatedGroups())); - } private function filterAllowedSectionToUser(array $userGroups, array $elementGroups): string diff --git a/src/Manager/RestrictionManagerInterface.php b/src/Manager/RestrictionManagerInterface.php index 4ccdc57c..21a2478c 100644 --- a/src/Manager/RestrictionManagerInterface.php +++ b/src/Manager/RestrictionManagerInterface.php @@ -1,5 +1,16 @@ classManager->getUserListing(); $memberListing->setCondition($condition, $conditionVariables); $memberListing->setUnpublished($includeUnpublished); diff --git a/src/Manager/UserManagerInterface.php b/src/Manager/UserManagerInterface.php index 7c7e767c..745de370 100644 --- a/src/Manager/UserManagerInterface.php +++ b/src/Manager/UserManagerInterface.php @@ -1,5 +1,16 @@ getDao()->getById($id); @@ -24,7 +35,7 @@ public static function getById(int $id): Restriction return $obj; } - public static function getByTargetId(int $id, string $cType = 'page'): Restriction + public static function getByTargetId(int $id, string $cType = 'page'): self { $obj = new self(); $obj->getDao()->getByField('targetId', $id, $cType); diff --git a/src/Security/Authenticator/OAuthIdentityAuthenticator.php b/src/Security/Authenticator/OAuthIdentityAuthenticator.php index 8e512e0a..a014b87d 100644 --- a/src/Security/Authenticator/OAuthIdentityAuthenticator.php +++ b/src/Security/Authenticator/OAuthIdentityAuthenticator.php @@ -1,5 +1,16 @@ getToken(), function () use ($accessToken, $client, $provider, $type, $parameter) { - $user = $client->fetchUserFromToken($accessToken); $oAuthResponse = new OAuthResponse($provider, $accessToken, $user, $parameter); $memberUser = $this->oAuthRegistrationHandler->getRefreshedUserFromUserResponse($oAuthResponse); diff --git a/src/Security/OAuth/AccountConnector.php b/src/Security/OAuth/AccountConnector.php index 7737dcc8..2d801508 100755 --- a/src/Security/OAuth/AccountConnector.php +++ b/src/Security/OAuth/AccountConnector.php @@ -1,5 +1,16 @@ leftJoin($aliasFrom, 'members_restrictions', 'mr', + $query->leftJoin( + $aliasFrom, + 'members_restrictions', + 'mr', sprintf('mr.targetId = %s.%s AND mr.ctype = "%s"', $aliasFrom, $queryIdentifier, $cType), ); - $query->leftJoin($aliasFrom, 'members_group_relations', 'mgr', + $query->leftJoin( + $aliasFrom, + 'members_group_relations', + 'mgr', 'mgr.restrictionId = mr.id' ); diff --git a/src/Security/RestrictionUri.php b/src/Security/RestrictionUri.php index 910f6e82..19925abe 100644 --- a/src/Security/RestrictionUri.php +++ b/src/Security/RestrictionUri.php @@ -1,5 +1,16 @@ restrictionManager->elementIsInProtectedStorageFolder($asset)) { - throw new \Exception(sprintf( + throw new \Exception( + sprintf( 'Asset "%s" is not in protected environment. Please move it to "%s"', $asset->getFullPath(), RestrictionManager::PROTECTED_ASSET_FOLDER diff --git a/src/Security/UserChecker.php b/src/Security/UserChecker.php index 682764f7..1864cca4 100644 --- a/src/Security/UserChecker.php +++ b/src/Security/UserChecker.php @@ -1,5 +1,16 @@ hasChanged() === false) { throw new EntityNotRefreshedException(sprintf('entity %d has not changed', $user->getId())); } - } public function addDefaults(UserInterface $user, ResourceOwnerInterface $resourceOwner, string $type): void diff --git a/src/Service/RestrictionService.php b/src/Service/RestrictionService.php index 2c944681..791748b2 100644 --- a/src/Service/RestrictionService.php +++ b/src/Service/RestrictionService.php @@ -1,13 +1,24 @@ isInherited() === false) { - $restriction->getDao()->delete(); $this->triggerEvent($obj, $restriction, MembersEvents::ENTITY_DELETE_RESTRICTION); @@ -235,7 +244,6 @@ public function findClosestInheritanceParent(int $elementId, string $cType): arr } foreach ($paths as $p) { - /** @var ElementInterface $el */ if ($el = $class::getByPath($p)) { $restriction = false; @@ -290,7 +298,6 @@ protected function updateRestrictionContext(ElementInterface $obj, string $cType if (!$hasParentRestriction) { if ($objectRestriction->isInherited()) { - $objectRestriction->getDao()->delete(); $this->triggerEvent($obj, $objectRestriction, MembersEvents::ENTITY_DELETE_RESTRICTION); diff --git a/src/Service/SsoIdentityStatusService.php b/src/Service/SsoIdentityStatusService.php index cd9171b2..ee65917c 100644 --- a/src/Service/SsoIdentityStatusService.php +++ b/src/Service/SsoIdentityStatusService.php @@ -1,13 +1,24 @@ getDao()->getIdByName($className); - } catch(NotFoundException $e) { + } catch (NotFoundException $e) { // fail silently } @@ -52,7 +63,6 @@ protected function getClasses(array $classes): array $result = []; foreach ($classes as $className) { - $filename = sprintf('class_%s_export.json', $className); $path = realpath(sprintf('%s/config/install/classes/%s', dirname(__DIR__, 2), $filename)); diff --git a/src/Tool/Install.php b/src/Tool/Install.php index f64e9fdb..08c21b1f 100644 --- a/src/Tool/Install.php +++ b/src/Tool/Install.php @@ -1,10 +1,20 @@ getGroups(); if (!empty($allowedGroups)) { - /** @var GroupInterface $group */ foreach ($allowedGroups as $group) { $groupIds[] = $group->getId(); diff --git a/src/Twig/Extension/OAuthExtension.php b/src/Twig/Extension/OAuthExtension.php index 3df42855..05696fe3 100644 --- a/src/Twig/Extension/OAuthExtension.php +++ b/src/Twig/Extension/OAuthExtension.php @@ -1,5 +1,16 @@