From c256dfe0543b7e6d06769903d9aa7f2c81153552 Mon Sep 17 00:00:00 2001 From: Michal Tomka Date: Wed, 31 Jul 2024 12:19:48 +0200 Subject: [PATCH 1/5] refactoring: registration mail is sent in `CustomerUserFacade::createCustomerUser` method --- app/src/DataFixtures/Demo/CompanyDataFixture.php | 2 +- app/src/Model/Customer/User/CustomerUserFacade.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/DataFixtures/Demo/CompanyDataFixture.php b/app/src/DataFixtures/Demo/CompanyDataFixture.php index c86df76ee4..14b0aac869 100644 --- a/app/src/DataFixtures/Demo/CompanyDataFixture.php +++ b/app/src/DataFixtures/Demo/CompanyDataFixture.php @@ -106,7 +106,7 @@ private function createCustomerUsers(Customer $customer): void foreach ($customersDataProvider as $customerDataProvider) { $deliveryAddress = $this->createDeliveryAddress($customer, $customerDataProvider[self::KEY_DELIVERY_ADDRESS]); $customerUserdata = $this->createCustomerUserData($customerDataProvider[self::KEY_CUSTOMER_USER_DATA], $customer->getDomainId(), $deliveryAddress); - $customerUser = $this->customerUserFacade->createCustomerUser($customer, $customerUserdata); + $customerUser = $this->customerUserFacade->createCustomerUserWithRegistrationMail($customer, $customerUserdata); $customerUserReference = $customerDataProvider[self::KEY_CUSTOMER_USER_DATA][self::KEY_CUSTOMER_USER_REFERENCE]; $this->addReferenceForDomain($customerUserReference, $customerUser, $customer->getDomainId()); diff --git a/app/src/Model/Customer/User/CustomerUserFacade.php b/app/src/Model/Customer/User/CustomerUserFacade.php index ecc3d5b83c..ff42b7f15d 100644 --- a/app/src/Model/Customer/User/CustomerUserFacade.php +++ b/app/src/Model/Customer/User/CustomerUserFacade.php @@ -34,6 +34,7 @@ * @method sendActivationMail(\App\Model\Customer\User\CustomerUser $customerUser) * @method setDefaultDeliveryAddress(\App\Model\Customer\User\CustomerUser $customerUser, \App\Model\Customer\DeliveryAddress $deliveryAddress) * @method \App\Model\Customer\User\CustomerUser editCustomerUser(int $id, \App\Model\Customer\User\CustomerUserData $customerUserData) + * @method \App\Model\Customer\User\CustomerUser createCustomerUserWithRegistrationMail(\Shopsys\FrameworkBundle\Model\Customer\Customer $customer, \App\Model\Customer\User\CustomerUserData $customerUserData) */ class CustomerUserFacade extends BaseCustomerUserFacade { From 4432a716a77d5f4176fc07e3d88547688f5086a5 Mon Sep 17 00:00:00 2001 From: Michal Tomka Date: Wed, 31 Jul 2024 12:20:22 +0200 Subject: [PATCH 2/5] refactoring: customer with addresses is created in `createCustomerWithAddresses` method --- app/src/Model/Customer/User/CustomerUserFacade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/Model/Customer/User/CustomerUserFacade.php b/app/src/Model/Customer/User/CustomerUserFacade.php index ff42b7f15d..a36c5cdebf 100644 --- a/app/src/Model/Customer/User/CustomerUserFacade.php +++ b/app/src/Model/Customer/User/CustomerUserFacade.php @@ -34,6 +34,7 @@ * @method sendActivationMail(\App\Model\Customer\User\CustomerUser $customerUser) * @method setDefaultDeliveryAddress(\App\Model\Customer\User\CustomerUser $customerUser, \App\Model\Customer\DeliveryAddress $deliveryAddress) * @method \App\Model\Customer\User\CustomerUser editCustomerUser(int $id, \App\Model\Customer\User\CustomerUserData $customerUserData) + * @method \Shopsys\FrameworkBundle\Model\Customer\Customer createCustomerWithAddresses(\App\Model\Customer\User\CustomerUserUpdateData $customerUserUpdateData) * @method \App\Model\Customer\User\CustomerUser createCustomerUserWithRegistrationMail(\Shopsys\FrameworkBundle\Model\Customer\Customer $customer, \App\Model\Customer\User\CustomerUserData $customerUserData) */ class CustomerUserFacade extends BaseCustomerUserFacade From bf9c82196c64c91bb244d6acf69873ac4c6e6c0c Mon Sep 17 00:00:00 2001 From: Michal Tomka Date: Wed, 31 Jul 2024 12:45:16 +0200 Subject: [PATCH 3/5] created new methods for sending activation --- app/src/DataFixtures/Demo/CompanyDataFixture.php | 2 +- app/src/Model/Customer/User/CustomerUserFacade.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/DataFixtures/Demo/CompanyDataFixture.php b/app/src/DataFixtures/Demo/CompanyDataFixture.php index 14b0aac869..02b51bc196 100644 --- a/app/src/DataFixtures/Demo/CompanyDataFixture.php +++ b/app/src/DataFixtures/Demo/CompanyDataFixture.php @@ -106,7 +106,7 @@ private function createCustomerUsers(Customer $customer): void foreach ($customersDataProvider as $customerDataProvider) { $deliveryAddress = $this->createDeliveryAddress($customer, $customerDataProvider[self::KEY_DELIVERY_ADDRESS]); $customerUserdata = $this->createCustomerUserData($customerDataProvider[self::KEY_CUSTOMER_USER_DATA], $customer->getDomainId(), $deliveryAddress); - $customerUser = $this->customerUserFacade->createCustomerUserWithRegistrationMail($customer, $customerUserdata); + $customerUser = $this->customerUserFacade->createCustomerUserWithActivationMail($customer, $customerUserdata); $customerUserReference = $customerDataProvider[self::KEY_CUSTOMER_USER_DATA][self::KEY_CUSTOMER_USER_REFERENCE]; $this->addReferenceForDomain($customerUserReference, $customerUser, $customer->getDomainId()); diff --git a/app/src/Model/Customer/User/CustomerUserFacade.php b/app/src/Model/Customer/User/CustomerUserFacade.php index a36c5cdebf..c0904e540a 100644 --- a/app/src/Model/Customer/User/CustomerUserFacade.php +++ b/app/src/Model/Customer/User/CustomerUserFacade.php @@ -36,6 +36,8 @@ * @method \App\Model\Customer\User\CustomerUser editCustomerUser(int $id, \App\Model\Customer\User\CustomerUserData $customerUserData) * @method \Shopsys\FrameworkBundle\Model\Customer\Customer createCustomerWithAddresses(\App\Model\Customer\User\CustomerUserUpdateData $customerUserUpdateData) * @method \App\Model\Customer\User\CustomerUser createCustomerUserWithRegistrationMail(\Shopsys\FrameworkBundle\Model\Customer\Customer $customer, \App\Model\Customer\User\CustomerUserData $customerUserData) + * @method \App\Model\Customer\User\CustomerUser createWithActivationMail(\App\Model\Customer\User\CustomerUserUpdateData $customerUserUpdateData) + * @method \App\Model\Customer\User\CustomerUser createCustomerUserWithActivationMail(\Shopsys\FrameworkBundle\Model\Customer\Customer $customer, \App\Model\Customer\User\CustomerUserData $customerUserData) */ class CustomerUserFacade extends BaseCustomerUserFacade { From 0166b59b58cb57c757a700c3c36422e95749c6bb Mon Sep 17 00:00:00 2001 From: Michal Tomka Date: Wed, 31 Jul 2024 15:44:09 +0200 Subject: [PATCH 4/5] allow admin to send an email for resetting password --- app/config/packages/security.yaml | 1 + app/src/Controller/Admin/CustomerController.php | 3 ++- app/tests/App/Smoke/Http/RouteConfigCustomization.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/config/packages/security.yaml b/app/config/packages/security.yaml index 085d947137..b8cbca16d1 100644 --- a/app/config/packages/security.yaml +++ b/app/config/packages/security.yaml @@ -229,6 +229,7 @@ security: - { path: ^/%admin_url%/billing-address/edit, roles: ROLE_CUSTOMER_FULL } - { path: ^/%admin_url%/customer/edit-personal-data/, roles: ROLE_CUSTOMER_FULL } - { path: ^/%admin_url%/customer/new-customer-user/, roles: ROLE_CUSTOMER_FULL } + - { path: ^/%admin_url%/customer/admin_customer_send_reset_password/, roles: ROLE_CUSTOMER_VIEW } - { path: ^/%admin_url%/delivery-address/edit, roles: ROLE_CUSTOMER_FULL } - { path: ^/%admin_url%/delivery-address/new, roles: ROLE_CUSTOMER_FULL } - { path: ^/%admin_url%/customer/, roles: ROLE_CUSTOMER_VIEW } diff --git a/app/src/Controller/Admin/CustomerController.php b/app/src/Controller/Admin/CustomerController.php index f4b04b7ea9..3c25241d88 100644 --- a/app/src/Controller/Admin/CustomerController.php +++ b/app/src/Controller/Admin/CustomerController.php @@ -13,8 +13,9 @@ * @property \App\Model\Customer\User\CustomerUserUpdateDataFactory $customerUserUpdateDataFactory * @property \App\Model\Customer\User\CustomerUserFacade $customerUserFacade * @method \App\Model\Administrator\Administrator getCurrentAdministrator() - * @method __construct(\App\Model\Customer\User\CustomerUserDataFactory $customerUserDataFactory, \Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserListAdminFacade $customerUserListAdminFacade, \App\Model\Customer\User\CustomerUserFacade $customerUserFacade, \Shopsys\FrameworkBundle\Model\AdminNavigation\BreadcrumbOverrider $breadcrumbOverrider, \Shopsys\FrameworkBundle\Model\Administrator\AdministratorGridFacade $administratorGridFacade, \Shopsys\FrameworkBundle\Component\Grid\GridFactory $gridFactory, \Shopsys\FrameworkBundle\Component\Domain\AdminDomainTabsFacade $adminDomainTabsFacade, \App\Model\Order\OrderFacade $orderFacade, \App\Model\Customer\User\CustomerUserUpdateDataFactory $customerUserUpdateDataFactory, \Shopsys\FrameworkBundle\Component\Domain\Domain $domain, \Shopsys\FrontendApiBundle\Model\Security\LoginAdministratorAsUserUrlProvider $loginAdministratorAsUserUrlProvider, \Shopsys\FrameworkBundle\Model\Customer\CustomerFacade $customerFacade) + * @method __construct(\App\Model\Customer\User\CustomerUserDataFactory $customerUserDataFactory, \Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserListAdminFacade $customerUserListAdminFacade, \App\Model\Customer\User\CustomerUserFacade $customerUserFacade, \Shopsys\FrameworkBundle\Model\AdminNavigation\BreadcrumbOverrider $breadcrumbOverrider, \Shopsys\FrameworkBundle\Model\Administrator\AdministratorGridFacade $administratorGridFacade, \Shopsys\FrameworkBundle\Component\Grid\GridFactory $gridFactory, \Shopsys\FrameworkBundle\Component\Domain\AdminDomainTabsFacade $adminDomainTabsFacade, \App\Model\Order\OrderFacade $orderFacade, \App\Model\Customer\User\CustomerUserUpdateDataFactory $customerUserUpdateDataFactory, \Shopsys\FrameworkBundle\Component\Domain\Domain $domain, \Shopsys\FrontendApiBundle\Model\Security\LoginAdministratorAsUserUrlProvider $loginAdministratorAsUserUrlProvider, \Shopsys\FrameworkBundle\Model\Customer\CustomerFacade $customerFacade, \App\Model\Customer\User\CustomerUserPasswordFacade $customerUserPasswordFacade) * @property \Shopsys\FrontendApiBundle\Model\Security\LoginAdministratorAsUserUrlProvider $loginAdministratorAsUserUrlProvider + * @property \App\Model\Customer\User\CustomerUserPasswordFacade $customerUserPasswordFacade */ class CustomerController extends BaseCustomerController { diff --git a/app/tests/App/Smoke/Http/RouteConfigCustomization.php b/app/tests/App/Smoke/Http/RouteConfigCustomization.php index 77a9476fc1..336186cbc9 100644 --- a/app/tests/App/Smoke/Http/RouteConfigCustomization.php +++ b/app/tests/App/Smoke/Http/RouteConfigCustomization.php @@ -130,7 +130,7 @@ private function configureGeneralRules(RouteConfigCustomizer $routeConfigCustomi } }) ->customize(function (RouteConfig $config, RouteInfo $info) { - if (preg_match('~(_delete$)|(_delete_all$)|(^admin_mail_deletetemplate$)|(^admin_(stock|store)_setdefault$)~', $info->getRouteName())) { + if (preg_match('~(_delete$)|(_delete_all$)|(^admin_mail_deletetemplate$)|(^admin_(stock|store)_setdefault$)|(^admin_customer_send_reset_password$)~', $info->getRouteName())) { $debugNote = 'Add CSRF token for any delete action during test execution. ' . '(Routes are protected by RouteCsrfProtector.)'; $config->changeDefaultRequestDataSet($debugNote) From 518e27a8cdb98470d580ae48ca57569db847cb08 Mon Sep 17 00:00:00 2001 From: Michal Tomka Date: Mon, 5 Aug 2024 14:33:59 +0200 Subject: [PATCH 5/5] change text constant --- storefront/components/Pages/NewPassword/NewPasswordContent.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storefront/components/Pages/NewPassword/NewPasswordContent.tsx b/storefront/components/Pages/NewPassword/NewPasswordContent.tsx index 290061982e..eaf301ec4a 100644 --- a/storefront/components/Pages/NewPassword/NewPasswordContent.tsx +++ b/storefront/components/Pages/NewPassword/NewPasswordContent.tsx @@ -103,7 +103,7 @@ export const NewPasswordContent: FC = ({ email, hash }) return ( -

{t('Login')}

+

{t('Set new password')}