From 96a10f5045d39436c44b770631b7afac3867f919 Mon Sep 17 00:00:00 2001 From: APaikens Date: Fri, 4 Sep 2015 23:33:44 +0300 Subject: [PATCH 01/33] Add option from config to clean expired passwords --- src/GoalioForgotPassword/Service/Password.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GoalioForgotPassword/Service/Password.php b/src/GoalioForgotPassword/Service/Password.php index 05154d9..a89ba68 100644 --- a/src/GoalioForgotPassword/Service/Password.php +++ b/src/GoalioForgotPassword/Service/Password.php @@ -45,8 +45,8 @@ public function findByEmail($email) public function cleanExpiredForgotRequests() { - // TODO: reset expiry time from options - return $this->getPasswordMapper()->cleanExpiredForgotRequests(); + $expireOption = $this->getOptions()->getResetExpire(); + return $this->getPasswordMapper()->cleanExpiredForgotRequests($expireOption); } public function cleanPriorForgotRequests($userId) From add865e49af8f83be4fa53b0485a70579c147fe4 Mon Sep 17 00:00:00 2001 From: APaikens Date: Mon, 27 Nov 2017 10:18:35 +0200 Subject: [PATCH 02/33] Allow zfcuser 3.0 Needed for ZF3 support --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 23d9148..c877202 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "require": { "goalio/goalio-mailservice": "1.*", - "zf-commons/zfc-user": "1.*" + "zf-commons/zfc-user": "3.*" }, "autoload": { "psr-0": { From dddc1a9237d809aa40ced47233f0f2bcabe0e94e Mon Sep 17 00:00:00 2001 From: APaikens Date: Mon, 27 Nov 2017 10:30:21 +0200 Subject: [PATCH 03/33] Bump goalio mailservice version To newest one --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c877202..2702628 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "goalio/goalio-mailservice": "1.*", + "goalio/goalio-mailservice": "2.*", "zf-commons/zfc-user": "3.*" }, "autoload": { From 60ba213f717a909cb5a77c96acc328520fc6506b Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 6 Feb 2018 10:28:26 +0200 Subject: [PATCH 04/33] Make controller via factory --- config/module.config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/module.config.php b/config/module.config.php index 8d1bc49..a7c9b5a 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -9,8 +9,8 @@ ), ), 'controllers' => array( - 'invokables' => array( - 'goalioforgotpassword_forgot' => 'GoalioForgotPassword\Controller\ForgotController', + 'factories' => array( + 'goalioforgotpassword_forgot' => 'GoalioForgotPassword\Factory\Controller\ForgotControllerFactory', ), ), From 0b73da9500f2106704ead5a475ddb809a6c5307e Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 6 Feb 2018 10:29:00 +0200 Subject: [PATCH 05/33] Drop serviceManager dependency Adjust to work with ZF3 --- .../Controller/ForgotController.php | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/GoalioForgotPassword/Controller/ForgotController.php b/src/GoalioForgotPassword/Controller/ForgotController.php index 52f3213..b910b5a 100644 --- a/src/GoalioForgotPassword/Controller/ForgotController.php +++ b/src/GoalioForgotPassword/Controller/ForgotController.php @@ -54,6 +54,15 @@ class ForgotController extends AbstractActionController */ protected $zfcUserOptions; + public function __construct($passwordService, $forgotForm, $resetForm, $userService, $options, $zfcUserOptions) { + $this->passwordService = $passwordService; + $this->forgotForm = $forgotForm; + $this->resetForm = $resetForm; + $this->userService = $userService; + $this->options = $options; + $this->zfcUserOptions = $zfcUserOptions; + } + /** * User page */ @@ -160,9 +169,6 @@ public function resetAction() public function getUserService() { - if (!$this->userService) { - $this->userService = $this->getServiceLocator()->get('zfcuser_user_service'); - } return $this->userService; } @@ -174,9 +180,6 @@ public function setUserService(UserService $userService) public function getPasswordService() { - if (!$this->passwordService) { - $this->passwordService = $this->getServiceLocator()->get('goalioforgotpassword_password_service'); - } return $this->passwordService; } @@ -188,9 +191,6 @@ public function setPasswordService(PasswordService $passwordService) public function getForgotForm() { - if (!$this->forgotForm) { - $this->setForgotForm($this->getServiceLocator()->get('goalioforgotpassword_forgot_form')); - } return $this->forgotForm; } @@ -201,9 +201,6 @@ public function setForgotForm(Form $forgotForm) public function getResetForm() { - if (!$this->resetForm) { - $this->setResetForm($this->getServiceLocator()->get('goalioforgotpassword_reset_form')); - } return $this->resetForm; } @@ -231,17 +228,11 @@ public function setOptions(ForgotControllerOptionsInterface $options) */ public function getOptions() { - if (!$this->options instanceof ForgotControllerOptionsInterface) { - $this->setOptions($this->getServiceLocator()->get('goalioforgotpassword_module_options')); - } return $this->options; } public function getZfcUserOptions() { - if (!$this->zfcUserOptions instanceof PasswordOptionsInterface) { - $this->zfcUserOptions = $this->getServiceLocator()->get('zfcuser_module_options'); - } return $this->zfcUserOptions; } } From b0785799c553b74675c925a9ad491ae5b640d67b Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 6 Feb 2018 10:29:49 +0200 Subject: [PATCH 06/33] Adjust to ZF3 --- .../Form/Service/ForgotFactory.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/GoalioForgotPassword/Form/Service/ForgotFactory.php b/src/GoalioForgotPassword/Form/Service/ForgotFactory.php index dc9a716..8c49b24 100644 --- a/src/GoalioForgotPassword/Form/Service/ForgotFactory.php +++ b/src/GoalioForgotPassword/Form/Service/ForgotFactory.php @@ -8,19 +8,23 @@ class ForgotFactory implements FactoryInterface { - public function createService(ServiceLocatorInterface $serviceLocator) { - $options = $serviceLocator->get('goalioforgotpassword_module_options'); + public function __invoke(\Interop\Container\ContainerInterface $container, $requestedName, array $options = NULL) { + $options = $container->get('goalioforgotpassword_module_options'); $form = new Forgot(null, $options); $validator = new \ZfcUser\Validator\RecordExists(array( - 'mapper' => $serviceLocator->get('zfcuser_user_mapper'), + 'mapper' => $container->get('zfcuser_user_mapper'), 'key' => 'email' )); - $translator = $serviceLocator->get('Translator'); + $translator = $container->get('MvcTranslator'); $validator->setMessage($translator->translate('The email address you entered was not found.')); $form->setInputFilter(new ForgotFilter($validator,$options)); return $form; } -} \ No newline at end of file + public function createService(ServiceLocatorInterface $serviceLocator) { + return $this->__invoke($serviceLocator,null); + } + +} From 9c96f27d9ebd63cff067cec87999bedcf3a320a8 Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 6 Feb 2018 10:30:21 +0200 Subject: [PATCH 07/33] Update to ZF3 --- src/GoalioForgotPassword/Mapper/PasswordHydrator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GoalioForgotPassword/Mapper/PasswordHydrator.php b/src/GoalioForgotPassword/Mapper/PasswordHydrator.php index 25b346b..fd99e9e 100644 --- a/src/GoalioForgotPassword/Mapper/PasswordHydrator.php +++ b/src/GoalioForgotPassword/Mapper/PasswordHydrator.php @@ -2,7 +2,7 @@ namespace GoalioForgotPassword\Mapper; -use Zend\Stdlib\Hydrator\ClassMethods; +use Zend\Hydrator\ClassMethods; use GoalioForgotPassword\Entity\Password as Entity; class PasswordHydrator extends ClassMethods From b0b10bd30c7752278781ff2475a56c944b5975b9 Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 6 Feb 2018 10:30:43 +0200 Subject: [PATCH 08/33] Update to ZF3 --- .../Mapper/Service/PasswordFactory.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/GoalioForgotPassword/Mapper/Service/PasswordFactory.php b/src/GoalioForgotPassword/Mapper/Service/PasswordFactory.php index 0d14ea5..0cafd24 100644 --- a/src/GoalioForgotPassword/Mapper/Service/PasswordFactory.php +++ b/src/GoalioForgotPassword/Mapper/Service/PasswordFactory.php @@ -5,17 +5,22 @@ use GoalioForgotPassword\Mapper\PasswordHydrator; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\ServiceManager\FactoryInterface; +use Interop\Container\ContainerInterface; class PasswordFactory implements FactoryInterface { - public function createService(ServiceLocatorInterface $serviceLocator) { - $options = $serviceLocator->get('goalioforgotpassword_module_options'); + public function __invoke(ContainerInterface $container, $requestedName, array $options = NULL) { + $options = $container->get('goalioforgotpassword_module_options'); $mapper = new Password(); - $mapper->setDbAdapter($serviceLocator->get('zfcuser_zend_db_adapter')); + $mapper->setDbAdapter($container->get('zfcuser_zend_db_adapter')); $entityClass = $options->getPasswordEntityClass(); $mapper->setEntityPrototype(new $entityClass); $mapper->setHydrator(new PasswordHydrator()); return $mapper; } -} \ No newline at end of file + public function createService(ServiceLocatorInterface $serviceLocator) { + return $this->__invoke($serviceLocator,null); + } + +} From 383e2e677edddef0fc070da2abdec92c058b93aa Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 6 Feb 2018 10:31:16 +0200 Subject: [PATCH 09/33] Move password service to factories --- src/GoalioForgotPassword/Module.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/GoalioForgotPassword/Module.php b/src/GoalioForgotPassword/Module.php index f90ff74..7aabc7b 100644 --- a/src/GoalioForgotPassword/Module.php +++ b/src/GoalioForgotPassword/Module.php @@ -28,7 +28,7 @@ public function getModuleDependencies() { public function getServiceConfig() { return array( 'invokables' => array( - 'goalioforgotpassword_password_service' => 'GoalioForgotPassword\Service\Password', + ), 'factories' => array( @@ -36,6 +36,7 @@ public function getServiceConfig() { 'goalioforgotpassword_forgot_form' => 'GoalioForgotPassword\Form\Service\ForgotFactory', 'goalioforgotpassword_reset_form' => 'GoalioForgotPassword\Form\Service\ResetFactory', 'goalioforgotpassword_password_mapper' => 'GoalioForgotPassword\Mapper\Service\PasswordFactory', + 'goalioforgotpassword_password_service' => 'GoalioForgotPassword\Factory\Service\PasswordFactory', ), ); } From 83f94feffc293e32ccc747336093d89c3029b1b8 Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 6 Feb 2018 10:31:46 +0200 Subject: [PATCH 10/33] Update to ZF3 --- .../Options/Service/ModuleOptionsFactory.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/GoalioForgotPassword/Options/Service/ModuleOptionsFactory.php b/src/GoalioForgotPassword/Options/Service/ModuleOptionsFactory.php index ccb1b24..bfca79b 100644 --- a/src/GoalioForgotPassword/Options/Service/ModuleOptionsFactory.php +++ b/src/GoalioForgotPassword/Options/Service/ModuleOptionsFactory.php @@ -7,9 +7,13 @@ class ModuleOptionsFactory implements FactoryInterface { - public function createService(ServiceLocatorInterface $serviceLocator) { - $config = $serviceLocator->get('Config'); + public function __invoke(\Interop\Container\ContainerInterface $container, $requestedName, array $options = NULL) { + $config = $container->get('Config'); return new ModuleOptions(isset($config['goalioforgotpassword']) ? $config['goalioforgotpassword'] : array()); } -} \ No newline at end of file + public function createService(ServiceLocatorInterface $serviceLocator) { + return $this->__invoke($serviceLocator,null); + } + +} From 90216e1f2c1e735b198804297786520af820028e Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 6 Feb 2018 10:32:20 +0200 Subject: [PATCH 11/33] Drop service manager dependency --- src/GoalioForgotPassword/Service/Password.php | 62 ++++--------------- 1 file changed, 12 insertions(+), 50 deletions(-) diff --git a/src/GoalioForgotPassword/Service/Password.php b/src/GoalioForgotPassword/Service/Password.php index a89ba68..838db05 100644 --- a/src/GoalioForgotPassword/Service/Password.php +++ b/src/GoalioForgotPassword/Service/Password.php @@ -2,25 +2,17 @@ namespace GoalioForgotPassword\Service; -use Zend\Mail\Transport\TransportInterface; - use ZfcUser\Options\PasswordOptionsInterface; use GoalioForgotPassword\Options\ForgotOptionsInterface; -use Zend\ServiceManager\ServiceManager; - -use Zend\ServiceManager\ServiceManagerAwareInterface; - use ZfcUser\Mapper\UserInterface as UserMapperInterface; use GoalioForgotPassword\Mapper\Password as PasswordMapper; use Zend\Crypt\Password\Bcrypt; -use Zend\Form\Form; - use ZfcBase\EventManager\EventProvider; -class Password extends EventProvider implements ServiceManagerAwareInterface +class Password extends EventProvider { /** * @var ModelMapper @@ -31,7 +23,16 @@ class Password extends EventProvider implements ServiceManagerAwareInterface protected $options; protected $zfcUserOptions; protected $emailRenderer; - protected $emailTransport; + protected $mailservice; + + public function __construct($options, $passwordMapper, $userMapper, $mailservice, $zfcUserOptions) + { + $this->options = $options; + $this->passwordMapper = $passwordMapper; + $this->userMapper = $userMapper; + $this->mailservice = $mailservice; + $this->zfcUserOptions = $zfcUserOptions; + } public function findByRequestKey($token) { @@ -77,7 +78,7 @@ public function sendProcessForgotRequest($userId, $email) public function sendForgotEmailMessage($to, $model) { - $mailService = $this->getServiceManager()->get('goaliomailservice_message'); + $mailService = $this->mailservice; $from = $this->getOptions()->getEmailFromAddress(); $subject = $this->getOptions()->getResetEmailSubjectLine(); @@ -106,17 +107,6 @@ public function resetPassword($password, $user, array $data) return true; } - public function getServiceManager() - { - return $this->serviceManager; - } - - public function setServiceManager(ServiceManager $serviceManager) - { - $this->serviceManager = $serviceManager; - return $this; - } - /** * getUserMapper * @@ -124,9 +114,6 @@ public function setServiceManager(ServiceManager $serviceManager) */ public function getUserMapper() { - if (null === $this->userMapper) { - $this->userMapper = $this->getServiceManager()->get('zfcuser_user_mapper'); - } return $this->userMapper; } @@ -150,10 +137,6 @@ public function setPasswordMapper(PasswordMapper $passwordMapper) public function getPasswordMapper() { - if (null === $this->passwordMapper) { - $this->setPasswordMapper($this->getServiceManager()->get('goalioforgotpassword_password_mapper')); - } - return $this->passwordMapper; } @@ -163,26 +146,8 @@ public function setMessageRenderer(ViewRenderer $emailRenderer) return $this; } - public function getMessageTransport() - { - if (!$this->emailTransport instanceof TransportInterface) { - $this->setEmailTransport($this->getServiceManager()->get('goalioforgotpassword_email_transport')); - } - - return $this->emailTransport; - } - - public function setMessageTransport(EmailTransport $emailTransport) - { - $this->emailTransport = $emailTransport; - return $this; - } - public function getOptions() { - if (!$this->options instanceof ForgotOptionsInterface) { - $this->setOptions($this->getServiceManager()->get('goalioforgotpassword_module_options')); - } return $this->options; } @@ -194,9 +159,6 @@ public function setOptions(ForgotOptionsInterface $opt) public function getZfcUserOptions() { - if (!$this->zfcUserOptions instanceof PasswordOptionsInterface) { - $this->setZfcUserOptions($this->getServiceManager()->get('zfcuser_module_options')); - } return $this->zfcUserOptions; } From 9b67ca4a2dddf8526b4bad0fea3440f3556574c6 Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 6 Feb 2018 10:37:19 +0200 Subject: [PATCH 12/33] Add missing factory --- .../Controller/ForgotControllerFactory.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/GoalioForgotPassword/Factory/Controller/ForgotControllerFactory.php diff --git a/src/GoalioForgotPassword/Factory/Controller/ForgotControllerFactory.php b/src/GoalioForgotPassword/Factory/Controller/ForgotControllerFactory.php new file mode 100644 index 0000000..6950047 --- /dev/null +++ b/src/GoalioForgotPassword/Factory/Controller/ForgotControllerFactory.php @@ -0,0 +1,34 @@ +get('goalioforgotpassword_password_service'), + $container->get('goalioforgotpassword_forgot_form'), + $container->get('goalioforgotpassword_reset_form'), + $container->get('zfcuser_user_service'), + $container->get('goalioforgotpassword_module_options'), + $container->get('zfcuser_module_options') + ); + + return $controller; + } + + public function createService(ServiceLocatorInterface $serviceLocator) { + return $this->__invoke($serviceLocator,null); + } +} From d02eba436d85279098f832ef5f3f8281ffa1dd99 Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 6 Feb 2018 10:39:32 +0200 Subject: [PATCH 13/33] Add factory needed for ZF3 --- .../Factory/Service/PasswordFactory.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/GoalioForgotPassword/Factory/Service/PasswordFactory.php diff --git a/src/GoalioForgotPassword/Factory/Service/PasswordFactory.php b/src/GoalioForgotPassword/Factory/Service/PasswordFactory.php new file mode 100644 index 0000000..232f73d --- /dev/null +++ b/src/GoalioForgotPassword/Factory/Service/PasswordFactory.php @@ -0,0 +1,32 @@ +get('goalioforgotpassword_module_options'), + $container->get('goalioforgotpassword_password_mapper'), + $container->get('zfcuser_user_mapper'), + $container->get('goaliomailservice_message'), + $container->get('zfcuser_module_options') + ); + + return $controller; + } + + public function createService(ServiceLocatorInterface $serviceLocator) { + return $this->__invoke($serviceLocator,null); + } +} From 91631424859f9fdfda28eeaa02624bf72946d2ec Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 8 May 2018 11:56:25 +0300 Subject: [PATCH 14/33] Remove unneded event Seems, that it's conflicting with latest ZF3 events --- src/GoalioForgotPassword/Form/Forgot.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/GoalioForgotPassword/Form/Forgot.php b/src/GoalioForgotPassword/Form/Forgot.php index 4ffd9dd..dd5390d 100644 --- a/src/GoalioForgotPassword/Form/Forgot.php +++ b/src/GoalioForgotPassword/Form/Forgot.php @@ -36,7 +36,6 @@ public function __construct($name = null, ForgotOptionsInterface $options) 'priority' => -100, )); - $this->getEventManager()->trigger('init', $this); } public function setForgotOptions(ForgotOptionsInterface $forgotOptions) From 956d9bd69baf4d0f7dba46b5c421ba0c28c18020 Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 8 May 2018 11:56:54 +0300 Subject: [PATCH 15/33] Remove unneded event initialisation --- src/GoalioForgotPassword/Form/Reset.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/GoalioForgotPassword/Form/Reset.php b/src/GoalioForgotPassword/Form/Reset.php index 07c15e5..83ed30f 100644 --- a/src/GoalioForgotPassword/Form/Reset.php +++ b/src/GoalioForgotPassword/Form/Reset.php @@ -50,7 +50,6 @@ public function __construct($name = null, ForgotOptionsInterface $forgotOptions) 'priority' => -100, )); - $this->getEventManager()->trigger('init', $this); } public function setForgotOptions(ForgotOptionsInterface $forgotOptions) From 5a0c32848d28de0f8f9b15771133c3fa40a68839 Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 8 May 2018 11:57:21 +0300 Subject: [PATCH 16/33] Remove unneded event initialisation --- src/GoalioForgotPassword/Form/ResetFilter.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/GoalioForgotPassword/Form/ResetFilter.php b/src/GoalioForgotPassword/Form/ResetFilter.php index 1371701..32c160c 100644 --- a/src/GoalioForgotPassword/Form/ResetFilter.php +++ b/src/GoalioForgotPassword/Form/ResetFilter.php @@ -47,6 +47,5 @@ public function __construct(ForgotOptionsInterface $options) ), )); - $this->getEventManager()->trigger('init', $this); } } From 88ae47847940f14b9c6dbe7a38fd1d1e77d8d647 Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 8 May 2018 11:58:23 +0300 Subject: [PATCH 17/33] Adjust factory to work with new ZF3 --- src/GoalioForgotPassword/Form/Service/ResetFactory.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/GoalioForgotPassword/Form/Service/ResetFactory.php b/src/GoalioForgotPassword/Form/Service/ResetFactory.php index c4830b0..5f88298 100644 --- a/src/GoalioForgotPassword/Form/Service/ResetFactory.php +++ b/src/GoalioForgotPassword/Form/Service/ResetFactory.php @@ -8,11 +8,15 @@ class ResetFactory implements FactoryInterface { - public function createService(ServiceLocatorInterface $serviceLocator) { - $options = $serviceLocator->get('goalioforgotpassword_module_options'); + public function __invoke(\Interop\Container\ContainerInterface $container, $requestedName, array $options = NULL) { + $options = $container->get('goalioforgotpassword_module_options'); $form = new Reset(null, $options); $form->setInputFilter(new ResetFilter($options)); return $form; } + public function createService(ServiceLocatorInterface $serviceLocator) { + return $this->__invoke($serviceLocator,null); + } + } From 9547cb4cfe29ef13379167b779ee48ede11a4e10 Mon Sep 17 00:00:00 2001 From: tarbidans Date: Fri, 3 Apr 2020 13:17:57 +0300 Subject: [PATCH 18/33] Migrated to Laminas using laminas-migration --- README.md | 10 +++++----- composer.json | 3 ++- config/goalioforgotpassword.global.php.dist | 4 ++-- .../Controller/ForgotController.php | 10 +++++----- .../Factory/Controller/ForgotControllerFactory.php | 4 ++-- .../Factory/Service/PasswordFactory.php | 4 ++-- src/GoalioForgotPassword/Form/Forgot.php | 2 +- src/GoalioForgotPassword/Form/ForgotFilter.php | 2 +- src/GoalioForgotPassword/Form/Reset.php | 4 ++-- .../Form/Service/ForgotFactory.php | 4 ++-- src/GoalioForgotPassword/Form/Service/ResetFactory.php | 4 ++-- src/GoalioForgotPassword/Mapper/Password.php | 2 +- src/GoalioForgotPassword/Mapper/PasswordHydrator.php | 2 +- .../Mapper/Service/PasswordFactory.php | 4 ++-- src/GoalioForgotPassword/Module.php | 6 +++--- src/GoalioForgotPassword/Options/ModuleOptions.php | 4 ++-- .../Options/Service/ModuleOptionsFactory.php | 4 ++-- src/GoalioForgotPassword/Service/Password.php | 2 +- .../Util/ServiceManagerFactory.php | 8 ++++---- 19 files changed, 42 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 4bfca59..5ff86a2 100644 --- a/README.md +++ b/README.md @@ -71,9 +71,9 @@ Installation 3. Make sure that the MailService is configured correctly. -### Post-Install: Zend\Db +### Post-Install: Laminas\Db -1. If you do not already have a valid Zend\Db\Adapter\Adapter in your service +1. If you do not already have a valid Laminas\Db\Adapter\Adapter in your service manager configuration, put the following in `./config/autoload/database.local.php`: array( 'factories' => array( - 'Zend\Db\Adapter\Adapter' => function ($sm) use ($dbParams) { - return new Zend\Db\Adapter\Adapter(array( + 'Laminas\Db\Adapter\Adapter' => function ($sm) use ($dbParams) { + return new Laminas\Db\Adapter\Adapter(array( 'driver' => 'pdo', 'dsn' => 'mysql:dbname='.$dbParams['database'].';host='.$dbParams['hostname'], 'database' => $dbParams['database'], @@ -126,7 +126,7 @@ The following options are available: - **reset_expire** - Integer value in seconds when the login cookie should expire. Default is `86400` (24 hours). - **email_transport** - String value which transport class to use. - Default is `Zend\Mail\Transport\Sendmail`. + Default is `Laminas\Mail\Transport\Sendmail`. - **reset_email_subject_line** - String value which transport class to use. Default is `You requested to reset your password`. - **email_from_address** - Array diff --git a/composer.json b/composer.json index 2702628..8b582fe 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ ], "require": { "goalio/goalio-mailservice": "2.*", - "zf-commons/zfc-user": "3.*" + "zf-commons/zfc-user": "3.*", + "laminas/laminas-dependency-plugin": "^1.0" }, "autoload": { "psr-0": { diff --git a/config/goalioforgotpassword.global.php.dist b/config/goalioforgotpassword.global.php.dist index dd86a81..cace21b 100644 --- a/config/goalioforgotpassword.global.php.dist +++ b/config/goalioforgotpassword.global.php.dist @@ -36,9 +36,9 @@ $settings = array( /** * Mail Transport to use * - * Default: 'Zend\Mail\Transport\Sendmail' + * Default: 'Laminas\Mail\Transport\Sendmail' */ - //'email_transport' => 'Zend\Mail\Transport\Sendmail', + //'email_transport' => 'Laminas\Mail\Transport\Sendmail', /** * Password Model Entity Class diff --git a/src/GoalioForgotPassword/Controller/ForgotController.php b/src/GoalioForgotPassword/Controller/ForgotController.php index b910b5a..ef42670 100644 --- a/src/GoalioForgotPassword/Controller/ForgotController.php +++ b/src/GoalioForgotPassword/Controller/ForgotController.php @@ -2,11 +2,11 @@ namespace GoalioForgotPassword\Controller; -use Zend\Form\Form; -use Zend\Mvc\Controller\AbstractActionController; -use Zend\Stdlib\ResponseInterface as Response; -use Zend\Stdlib\Parameters; -use Zend\View\Model\ViewModel; +use Laminas\Form\Form; +use Laminas\Mvc\Controller\AbstractActionController; +use Laminas\Stdlib\ResponseInterface as Response; +use Laminas\Stdlib\Parameters; +use Laminas\View\Model\ViewModel; use GoalioForgotPassword\Service\Password as PasswordService; use GoalioForgotPassword\Options\ForgotControllerOptionsInterface; diff --git a/src/GoalioForgotPassword/Factory/Controller/ForgotControllerFactory.php b/src/GoalioForgotPassword/Factory/Controller/ForgotControllerFactory.php index 6950047..0533de1 100644 --- a/src/GoalioForgotPassword/Factory/Controller/ForgotControllerFactory.php +++ b/src/GoalioForgotPassword/Factory/Controller/ForgotControllerFactory.php @@ -2,8 +2,8 @@ namespace GoalioForgotPassword\Factory\Controller; -use Zend\ServiceManager\FactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; use \Interop\Container\ContainerInterface; use GoalioForgotPassword\Controller\ForgotController; diff --git a/src/GoalioForgotPassword/Factory/Service/PasswordFactory.php b/src/GoalioForgotPassword/Factory/Service/PasswordFactory.php index 232f73d..23cee9c 100644 --- a/src/GoalioForgotPassword/Factory/Service/PasswordFactory.php +++ b/src/GoalioForgotPassword/Factory/Service/PasswordFactory.php @@ -2,8 +2,8 @@ namespace GoalioForgotPassword\Factory\Service; -use Zend\ServiceManager\FactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; use Interop\Container\ContainerInterface; use GoalioForgotPassword\Service\Password; diff --git a/src/GoalioForgotPassword/Form/Forgot.php b/src/GoalioForgotPassword/Form/Forgot.php index dd5390d..748845e 100644 --- a/src/GoalioForgotPassword/Form/Forgot.php +++ b/src/GoalioForgotPassword/Form/Forgot.php @@ -2,7 +2,7 @@ namespace GoalioForgotPassword\Form; -use Zend\Form\Element; +use Laminas\Form\Element; use ZfcBase\Form\ProvidesEventsForm; use GoalioForgotPassword\Options\ForgotOptionsInterface; diff --git a/src/GoalioForgotPassword/Form/ForgotFilter.php b/src/GoalioForgotPassword/Form/ForgotFilter.php index 93067cd..b9d1917 100644 --- a/src/GoalioForgotPassword/Form/ForgotFilter.php +++ b/src/GoalioForgotPassword/Form/ForgotFilter.php @@ -2,7 +2,7 @@ namespace GoalioForgotPassword\Form; -use Zend\InputFilter\InputFilter; +use Laminas\InputFilter\InputFilter; use GoalioForgotPassword\Options\ForgotOptionsInterface; class ForgotFilter extends InputFilter diff --git a/src/GoalioForgotPassword/Form/Reset.php b/src/GoalioForgotPassword/Form/Reset.php index 83ed30f..703e2e8 100644 --- a/src/GoalioForgotPassword/Form/Reset.php +++ b/src/GoalioForgotPassword/Form/Reset.php @@ -2,8 +2,8 @@ namespace GoalioForgotPassword\Form; -use Zend\Form\Form; -use Zend\Form\Element; +use Laminas\Form\Form; +use Laminas\Form\Element; use ZfcBase\Form\ProvidesEventsForm; use GoalioForgotPassword\Options\ForgotOptionsInterface; diff --git a/src/GoalioForgotPassword/Form/Service/ForgotFactory.php b/src/GoalioForgotPassword/Form/Service/ForgotFactory.php index 8c49b24..e7fd301 100644 --- a/src/GoalioForgotPassword/Form/Service/ForgotFactory.php +++ b/src/GoalioForgotPassword/Form/Service/ForgotFactory.php @@ -3,8 +3,8 @@ use GoalioForgotPassword\Form\Forgot; use GoalioForgotPassword\Form\ForgotFilter; -use Zend\ServiceManager\ServiceLocatorInterface; -use Zend\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\FactoryInterface; class ForgotFactory implements FactoryInterface { diff --git a/src/GoalioForgotPassword/Form/Service/ResetFactory.php b/src/GoalioForgotPassword/Form/Service/ResetFactory.php index 5f88298..c82fe6d 100644 --- a/src/GoalioForgotPassword/Form/Service/ResetFactory.php +++ b/src/GoalioForgotPassword/Form/Service/ResetFactory.php @@ -3,8 +3,8 @@ use GoalioForgotPassword\Form\Reset; use GoalioForgotPassword\Form\ResetFilter; -use Zend\ServiceManager\ServiceLocatorInterface; -use Zend\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\FactoryInterface; class ResetFactory implements FactoryInterface { diff --git a/src/GoalioForgotPassword/Mapper/Password.php b/src/GoalioForgotPassword/Mapper/Password.php index 145e13c..e69d106 100644 --- a/src/GoalioForgotPassword/Mapper/Password.php +++ b/src/GoalioForgotPassword/Mapper/Password.php @@ -3,7 +3,7 @@ use ZfcBase\Mapper\AbstractDbMapper; use GoalioForgotPassword\Entity\Password as Model; -use Zend\Db\Sql\Sql; +use Laminas\Db\Sql\Sql; class Password extends AbstractDbMapper { diff --git a/src/GoalioForgotPassword/Mapper/PasswordHydrator.php b/src/GoalioForgotPassword/Mapper/PasswordHydrator.php index fd99e9e..821080b 100644 --- a/src/GoalioForgotPassword/Mapper/PasswordHydrator.php +++ b/src/GoalioForgotPassword/Mapper/PasswordHydrator.php @@ -2,7 +2,7 @@ namespace GoalioForgotPassword\Mapper; -use Zend\Hydrator\ClassMethods; +use Laminas\Hydrator\ClassMethods; use GoalioForgotPassword\Entity\Password as Entity; class PasswordHydrator extends ClassMethods diff --git a/src/GoalioForgotPassword/Mapper/Service/PasswordFactory.php b/src/GoalioForgotPassword/Mapper/Service/PasswordFactory.php index 0cafd24..1c1373c 100644 --- a/src/GoalioForgotPassword/Mapper/Service/PasswordFactory.php +++ b/src/GoalioForgotPassword/Mapper/Service/PasswordFactory.php @@ -3,8 +3,8 @@ use GoalioForgotPassword\Mapper\Password; use GoalioForgotPassword\Mapper\PasswordHydrator; -use Zend\ServiceManager\ServiceLocatorInterface; -use Zend\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\FactoryInterface; use Interop\Container\ContainerInterface; class PasswordFactory implements FactoryInterface { diff --git a/src/GoalioForgotPassword/Module.php b/src/GoalioForgotPassword/Module.php index 7aabc7b..9682e8d 100644 --- a/src/GoalioForgotPassword/Module.php +++ b/src/GoalioForgotPassword/Module.php @@ -1,9 +1,9 @@ setService('ApplicationConfig', static::$config); - $serviceManager->setFactory('ServiceListener', 'Zend\Mvc\Service\ServiceListenerFactory'); + $serviceManager->setFactory('ServiceListener', 'Laminas\Mvc\Service\ServiceListenerFactory'); - /** @var $moduleManager \Zend\ModuleManager\ModuleManager */ + /** @var $moduleManager \Laminas\ModuleManager\ModuleManager */ $moduleManager = $serviceManager->get('ModuleManager'); $moduleManager->loadModules(); //$serviceManager->setAllowOverride(true); From 6e4c5cba75287c6f7991cf7145bc4db05f684834 Mon Sep 17 00:00:00 2001 From: APaikens Date: Mon, 6 Apr 2020 16:07:41 +0300 Subject: [PATCH 19/33] Update composer.json Bump mail service and zfc user version --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 8b582fe..59435c6 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,8 @@ } ], "require": { - "goalio/goalio-mailservice": "2.*", - "zf-commons/zfc-user": "3.*", + "goalio/goalio-mailservice": "^3.0", + "zf-commons/zfc-user": "4.*", "laminas/laminas-dependency-plugin": "^1.0" }, "autoload": { From f38a324e521d462fe2de8502efb4d51d5be1b25f Mon Sep 17 00:00:00 2001 From: Andris Paikens Date: Tue, 7 Apr 2020 13:41:35 +0300 Subject: [PATCH 20/33] Remove zfcBase and events Cleanup --- README.md | 4 +--- src/GoalioForgotPassword/Form/Forgot.php | 4 ++-- src/GoalioForgotPassword/Form/Reset.php | 3 +-- src/GoalioForgotPassword/Form/ResetFilter.php | 2 +- src/GoalioForgotPassword/Mapper/Password.php | 2 +- src/GoalioForgotPassword/Module.php | 2 +- src/GoalioForgotPassword/Service/Password.php | 6 +----- 7 files changed, 8 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 5ff86a2..f44f745 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,7 @@ can be a little slow because we are a small company with only two developers. I Requirements ------------ -* [Zend Framework 2](https://github.com/zendframework/zf2) (latest master). -* [ZfcBase](https://github.com/ZF-Commons/ZfcBase) (latest master). +* [Laminas]() (latest master). * [ZfcUser](https://github.com/ZF-Commons/ZfcUser) (latest master). * [GoalioMailService](https://github.com/goalio/GoalioMailService) (latest master). @@ -58,7 +57,6 @@ Installation return array( 'modules' => array( // ... - 'ZfcBase', 'ZfcUser', 'GoalioMailService', 'GoalioForgotPassword' diff --git a/src/GoalioForgotPassword/Form/Forgot.php b/src/GoalioForgotPassword/Form/Forgot.php index 748845e..b47e176 100644 --- a/src/GoalioForgotPassword/Form/Forgot.php +++ b/src/GoalioForgotPassword/Form/Forgot.php @@ -3,10 +3,10 @@ namespace GoalioForgotPassword\Form; use Laminas\Form\Element; -use ZfcBase\Form\ProvidesEventsForm; +use Laminas\Form\Form; use GoalioForgotPassword\Options\ForgotOptionsInterface; -class Forgot extends ProvidesEventsForm +class Forgot extends Form { /** * @var AuthenticationOptionsInterface diff --git a/src/GoalioForgotPassword/Form/Reset.php b/src/GoalioForgotPassword/Form/Reset.php index 703e2e8..8fede34 100644 --- a/src/GoalioForgotPassword/Form/Reset.php +++ b/src/GoalioForgotPassword/Form/Reset.php @@ -4,10 +4,9 @@ use Laminas\Form\Form; use Laminas\Form\Element; -use ZfcBase\Form\ProvidesEventsForm; use GoalioForgotPassword\Options\ForgotOptionsInterface; -class Reset extends ProvidesEventsForm +class Reset extends Form { /** * @var ForgotOptionsInterface diff --git a/src/GoalioForgotPassword/Form/ResetFilter.php b/src/GoalioForgotPassword/Form/ResetFilter.php index 32c160c..ebfec52 100644 --- a/src/GoalioForgotPassword/Form/ResetFilter.php +++ b/src/GoalioForgotPassword/Form/ResetFilter.php @@ -2,7 +2,7 @@ namespace GoalioForgotPassword\Form; -use ZfcBase\InputFilter\ProvidesEventsInputFilter as InputFilter; +use Laminas\InputFilter\InputFilter; use GoalioForgotPassword\Options\ForgotOptionsInterface; class ResetFilter extends InputFilter diff --git a/src/GoalioForgotPassword/Mapper/Password.php b/src/GoalioForgotPassword/Mapper/Password.php index e69d106..d7b37c0 100644 --- a/src/GoalioForgotPassword/Mapper/Password.php +++ b/src/GoalioForgotPassword/Mapper/Password.php @@ -1,7 +1,7 @@ setUserId($userId); $model->setRequestTime(new \DateTime('now')); $model->generateRequestKey(); - $this->getEventManager()->trigger(__FUNCTION__, $this, array('record' => $model, 'userId' => $userId)); $this->getPasswordMapper()->persist($model); $this->sendForgotEmailMessage($email, $model); @@ -99,10 +97,8 @@ public function resetPassword($password, $user, array $data) $pass = $bcrypt->create($newPass); $user->setPassword($pass); - $this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $user)); $this->getUserMapper()->update($user); $this->remove($password); - $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('user' => $user)); return true; } From b35942985ba0bf898b915c75fbbc6d77d410334d Mon Sep 17 00:00:00 2001 From: Andris Paikens Date: Tue, 7 Apr 2020 13:42:06 +0300 Subject: [PATCH 21/33] add db mapper --- .../Mapper/AbstractDbMapper.php | 339 ++++++++++++++++++ 1 file changed, 339 insertions(+) create mode 100644 src/GoalioForgotPassword/Mapper/AbstractDbMapper.php diff --git a/src/GoalioForgotPassword/Mapper/AbstractDbMapper.php b/src/GoalioForgotPassword/Mapper/AbstractDbMapper.php new file mode 100644 index 0000000..f4cec4a --- /dev/null +++ b/src/GoalioForgotPassword/Mapper/AbstractDbMapper.php @@ -0,0 +1,339 @@ +isInitialized) { + return; + } + + if (!$this->dbAdapter instanceof Adapter) { + throw new \Exception('No db adapter present'); + } + + if (!$this->hydrator instanceof HydratorInterface) { + $this->hydrator = new ClassMethods; + } + + if (!is_object($this->entityPrototype)) { + throw new \Exception('No entity prototype set'); + } + + $this->isInitialized = true; + } + + /** + * @param string|null $table + * @return Select + */ + protected function getSelect($table = null) + { + $this->initialize(); + return $this->getSlaveSql()->select($table ?: $this->getTableName()); + } + + /** + * @param Select $select + * @param object|null $entityPrototype + * @param HydratorInterface|null $hydrator + * @return HydratingResultSet + */ + protected function select(Select $select, $entityPrototype = null, HydratorInterface $hydrator = null) + { + $this->initialize(); + + $stmt = $this->getSlaveSql()->prepareStatementForSqlObject($select); + + $resultSet = new HydratingResultSet($hydrator ?: $this->getHydrator(), + $entityPrototype ?: $this->getEntityPrototype()); + + $resultSet->initialize($stmt->execute()); + return $resultSet; + } + + /** + * @param object|array $entity + * @param string|TableIdentifier|null $tableName + * @param HydratorInterface|null $hydrator + * @return ResultInterface + */ + protected function insert($entity, $tableName = null, HydratorInterface $hydrator = null) + { + $this->initialize(); + $tableName = $tableName ?: $this->tableName; + + $sql = $this->getSql()->setTable($tableName); + $insert = $sql->insert(); + + $rowData = $this->entityToArray($entity, $hydrator); + $insert->values($rowData); + + $statement = $sql->prepareStatementForSqlObject($insert); + + return $statement->execute(); + } + + /** + * @param object|array $entity + * @param string|array|\Closure $where + * @param string|TableIdentifier|null $tableName + * @param HydratorInterface|null $hydrator + * @return ResultInterface + */ + protected function update($entity, $where, $tableName = null, HydratorInterface $hydrator = null) + { + $this->initialize(); + $tableName = $tableName ?: $this->tableName; + + $sql = $this->getSql()->setTable($tableName); + $update = $sql->update(); + + $rowData = $this->entityToArray($entity, $hydrator); + $update->set($rowData) + ->where($where); + + $statement = $sql->prepareStatementForSqlObject($update); + + return $statement->execute(); + } + + /** + * @param string|array|\Closure $where + * @param string|TableIdentifier|null $tableName + * @return ResultInterface + */ + protected function delete($where, $tableName = null) + { + $tableName = $tableName ?: $this->tableName; + + $sql = $this->getSql()->setTable($tableName); + $delete = $sql->delete(); + + $delete->where($where); + + $statement = $sql->prepareStatementForSqlObject($delete); + + return $statement->execute(); + } + + /** + * @return string + */ + protected function getTableName() + { + return $this->tableName; + } + + /** + * @return object + */ + public function getEntityPrototype() + { + return $this->entityPrototype; + } + + /** + * @param object $entityPrototype + * @return AbstractDbMapper + */ + public function setEntityPrototype($entityPrototype) + { + $this->entityPrototype = $entityPrototype; + $this->resultSetPrototype = null; + return $this; + } + + /** + * @return Adapter + */ + public function getDbAdapter() + { + return $this->dbAdapter; + } + + /** + * @param Adapter $dbAdapter + * @return AbstractDbMapper + */ + public function setDbAdapter(Adapter $dbAdapter) + { + $this->dbAdapter = $dbAdapter; + if ($dbAdapter instanceof MasterSlaveAdapterInterface) { + $this->setDbSlaveAdapter($dbAdapter->getSlaveAdapter()); + } + return $this; + } + + /** + * @return Adapter + */ + public function getDbSlaveAdapter() + { + return $this->dbSlaveAdapter ?: $this->dbAdapter; + } + + /** + * @param Adapter $dbSlaveAdapter + * @return AbstractDbMapper + */ + public function setDbSlaveAdapter(Adapter $dbSlaveAdapter) + { + $this->dbSlaveAdapter = $dbSlaveAdapter; + return $this; + } + + /** + * @return HydratorInterface + */ + public function getHydrator() + { + if (!$this->hydrator) { + $this->hydrator = new ClassMethods(false); + } + return $this->hydrator; + } + + /** + * @param HydratorInterface $hydrator + * @return AbstractDbMapper + */ + public function setHydrator(HydratorInterface $hydrator) + { + $this->hydrator = $hydrator; + $this->resultSetPrototype = null; + return $this; + } + + /** + * @return Sql + */ + protected function getSql() + { + if (!$this->sql instanceof Sql) { + $this->sql = new Sql($this->getDbAdapter()); + } + + return $this->sql; + } + + /** + * @param Sql $sql + * @return AbstractDbMapper + */ + protected function setSql(Sql $sql) + { + $this->sql = $sql; + return $this; + } + + /** + * @return Sql + */ + protected function getSlaveSql() + { + if (!$this->slaveSql instanceof Sql) { + $this->slaveSql = new Sql($this->getDbSlaveAdapter()); + } + + return $this->slaveSql; + } + + /** + * @param Sql $sql + * @return AbstractDbMapper + */ + protected function setSlaveSql(Sql $sql) + { + $this->slaveSql = $sql; + return $this; + } + + /** + * Uses the hydrator to convert the entity to an array. + * + * Use this method to ensure that you're working with an array. + * + * @param object $entity + * @param HydratorInterface|null $hydrator + * @return array + */ + protected function entityToArray($entity, HydratorInterface $hydrator = null) + { + if (is_array($entity)) { + return $entity; // cut down on duplicate code + } elseif (is_object($entity)) { + if (!$hydrator) { + $hydrator = $this->getHydrator(); + } + return $hydrator->extract($entity); + } + throw new Exception\InvalidArgumentException('Entity passed to db mapper should be an array or object.'); + } +} From 66ffc35a579eb0a40c6bd696c562da36028c27cf Mon Sep 17 00:00:00 2001 From: APaikens Date: Thu, 7 Jan 2021 15:55:23 +0200 Subject: [PATCH 22/33] Update composer.json Remove unneded laminas depenency plugin --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 59435c6..c9d4929 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,7 @@ ], "require": { "goalio/goalio-mailservice": "^3.0", - "zf-commons/zfc-user": "4.*", - "laminas/laminas-dependency-plugin": "^1.0" + "zf-commons/zfc-user": "4.*" }, "autoload": { "psr-0": { From 55a6635f7678e4d38ac1e39f710c457bfd8ec4bf Mon Sep 17 00:00:00 2001 From: Roberts <15999503+RPencis@users.noreply.github.com> Date: Wed, 1 Sep 2021 14:53:13 +0300 Subject: [PATCH 23/33] phpStan scan fixes fixes based on phpStan returned errors --- src/GoalioForgotPassword/Form/ForgotFilter.php | 2 ++ src/GoalioForgotPassword/Mapper/AbstractDbMapper.php | 2 +- src/GoalioForgotPassword/Mapper/PasswordHydrator.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/GoalioForgotPassword/Form/ForgotFilter.php b/src/GoalioForgotPassword/Form/ForgotFilter.php index b9d1917..e5e4f3b 100644 --- a/src/GoalioForgotPassword/Form/ForgotFilter.php +++ b/src/GoalioForgotPassword/Form/ForgotFilter.php @@ -12,6 +12,8 @@ class ForgotFilter extends InputFilter */ protected $options; + protected $emailValidator; + public function __construct( $emailValidator, ForgotOptionsInterface $options) { $this->setOptions($options); diff --git a/src/GoalioForgotPassword/Mapper/AbstractDbMapper.php b/src/GoalioForgotPassword/Mapper/AbstractDbMapper.php index f4cec4a..66351ed 100644 --- a/src/GoalioForgotPassword/Mapper/AbstractDbMapper.php +++ b/src/GoalioForgotPassword/Mapper/AbstractDbMapper.php @@ -334,6 +334,6 @@ protected function entityToArray($entity, HydratorInterface $hydrator = null) } return $hydrator->extract($entity); } - throw new Exception\InvalidArgumentException('Entity passed to db mapper should be an array or object.'); + throw new \InvalidArgumentException('Entity passed to db mapper should be an array or object.'); } } diff --git a/src/GoalioForgotPassword/Mapper/PasswordHydrator.php b/src/GoalioForgotPassword/Mapper/PasswordHydrator.php index 821080b..615ff35 100644 --- a/src/GoalioForgotPassword/Mapper/PasswordHydrator.php +++ b/src/GoalioForgotPassword/Mapper/PasswordHydrator.php @@ -14,7 +14,7 @@ class PasswordHydrator extends ClassMethods * @return array * @throws Exception\InvalidArgumentException */ - public function extract($object) + public function extract(object $object):array { if (!$object instanceof Entity) { throw new \InvalidArgumentException('$object must be an instance of EmailVerification entity'); From 450083eccadbbaab7ea228bea43c1385f0b713e4 Mon Sep 17 00:00:00 2001 From: APaikens Date: Fri, 4 Mar 2022 10:06:03 +0200 Subject: [PATCH 24/33] Update mapper to work with latest hydrator --- src/GoalioForgotPassword/Mapper/PasswordHydrator.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/GoalioForgotPassword/Mapper/PasswordHydrator.php b/src/GoalioForgotPassword/Mapper/PasswordHydrator.php index 615ff35..d39a2d6 100644 --- a/src/GoalioForgotPassword/Mapper/PasswordHydrator.php +++ b/src/GoalioForgotPassword/Mapper/PasswordHydrator.php @@ -2,10 +2,11 @@ namespace GoalioForgotPassword\Mapper; -use Laminas\Hydrator\ClassMethods; +//use Laminas\Hydrator\ClassMethods; +use Laminas\Hydrator\ClassMethodsHydrator; use GoalioForgotPassword\Entity\Password as Entity; -class PasswordHydrator extends ClassMethods +class PasswordHydrator extends ClassMethodsHydrator { /** * Extract values from an object From 624b4fdfc1335875686ccf1d97d183a3a9e9d64d Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 13 Sep 2022 15:57:31 +0300 Subject: [PATCH 25/33] Set name as mandatory element for form creation --- src/GoalioForgotPassword/Form/Forgot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GoalioForgotPassword/Form/Forgot.php b/src/GoalioForgotPassword/Form/Forgot.php index b47e176..b925c54 100644 --- a/src/GoalioForgotPassword/Form/Forgot.php +++ b/src/GoalioForgotPassword/Form/Forgot.php @@ -13,7 +13,7 @@ class Forgot extends Form */ protected $forgotOptions; - public function __construct($name = null, ForgotOptionsInterface $options) + public function __construct($name, ForgotOptionsInterface $options) { $this->setForgotOptions($options); parent::__construct($name); From 06bc6a2cc4436f2f8bb20bb47ed8a6933440ea9b Mon Sep 17 00:00:00 2001 From: APaikens Date: Tue, 13 Sep 2022 16:05:28 +0300 Subject: [PATCH 26/33] Set name as mandatory element for reset form creation --- src/GoalioForgotPassword/Form/Reset.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GoalioForgotPassword/Form/Reset.php b/src/GoalioForgotPassword/Form/Reset.php index 8fede34..b2eb102 100644 --- a/src/GoalioForgotPassword/Form/Reset.php +++ b/src/GoalioForgotPassword/Form/Reset.php @@ -13,7 +13,7 @@ class Reset extends Form */ protected $forgotOptions; - public function __construct($name = null, ForgotOptionsInterface $forgotOptions) + public function __construct($name, ForgotOptionsInterface $forgotOptions) { $this->setForgotOptions($forgotOptions); parent::__construct($name); From 4ac4699e10a34890eade9fc16f5383edbd8c2006 Mon Sep 17 00:00:00 2001 From: martinsDzirnieks <77049636+martinsDzirnieks@users.noreply.github.com> Date: Tue, 29 Nov 2022 13:25:28 +0200 Subject: [PATCH 27/33] Update ResetFilter.php --- src/GoalioForgotPassword/Form/ResetFilter.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/GoalioForgotPassword/Form/ResetFilter.php b/src/GoalioForgotPassword/Form/ResetFilter.php index ebfec52..cc29412 100644 --- a/src/GoalioForgotPassword/Form/ResetFilter.php +++ b/src/GoalioForgotPassword/Form/ResetFilter.php @@ -7,8 +7,10 @@ class ResetFilter extends InputFilter { - public function __construct(ForgotOptionsInterface $options) + protected $passwordValidator; + public function __construct(ForgotOptionsInterface $options, $passwordValidator, $config) { + $this->passwordValidator = $passwordValidator; $this->add(array( 'name' => 'newCredential', 'required' => true, @@ -16,9 +18,10 @@ public function __construct(ForgotOptionsInterface $options) array( 'name' => 'StringLength', 'options' => array( - 'min' => 6, + 'min' => $config['minPasswordLength'], ), ), + $this->passwordValidator, ), 'filters' => array( array('name' => 'StringTrim'), @@ -32,7 +35,7 @@ public function __construct(ForgotOptionsInterface $options) array( 'name' => 'StringLength', 'options' => array( - 'min' => 6, + 'min' => $config['minPasswordLength'], ), ), array( @@ -41,6 +44,7 @@ public function __construct(ForgotOptionsInterface $options) 'token' => 'newCredential' ) ), + $this->passwordValidator, ), 'filters' => array( array('name' => 'StringTrim'), From 00bd492a6babece96467e1f47d34a883ed7f887a Mon Sep 17 00:00:00 2001 From: martinsDzirnieks <77049636+martinsDzirnieks@users.noreply.github.com> Date: Tue, 29 Nov 2022 13:28:58 +0200 Subject: [PATCH 28/33] Update ResetFactory.php --- src/GoalioForgotPassword/Form/Service/ResetFactory.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/GoalioForgotPassword/Form/Service/ResetFactory.php b/src/GoalioForgotPassword/Form/Service/ResetFactory.php index c82fe6d..578b030 100644 --- a/src/GoalioForgotPassword/Form/Service/ResetFactory.php +++ b/src/GoalioForgotPassword/Form/Service/ResetFactory.php @@ -5,13 +5,21 @@ use GoalioForgotPassword\Form\ResetFilter; use Laminas\ServiceManager\ServiceLocatorInterface; use Laminas\ServiceManager\FactoryInterface; +use DiviUser\Validator\PasswordIsValid; class ResetFactory implements FactoryInterface { public function __invoke(\Interop\Container\ContainerInterface $container, $requestedName, array $options = NULL) { $options = $container->get('goalioforgotpassword_module_options'); + $config = $container->get('config'); $form = new Reset(null, $options); - $form->setInputFilter(new ResetFilter($options)); + $form->setInputFilter(new ResetFilter($options, + new PasswordIsValid( + $container->get('zfcuser_module_options'), + $config['zfcuser'] + ), + $config['zfcuser'], + )); return $form; } From 607a4a0113be1c89216cf96f7b85067926024a60 Mon Sep 17 00:00:00 2001 From: Oskars Granapskis Date: Wed, 26 Apr 2023 12:41:02 +0300 Subject: [PATCH 29/33] add a trigger on password reset --- src/GoalioForgotPassword/Service/Password.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/GoalioForgotPassword/Service/Password.php b/src/GoalioForgotPassword/Service/Password.php index f668b5a..4f39196 100644 --- a/src/GoalioForgotPassword/Service/Password.php +++ b/src/GoalioForgotPassword/Service/Password.php @@ -10,8 +10,9 @@ use GoalioForgotPassword\Mapper\Password as PasswordMapper; use Laminas\Crypt\Password\Bcrypt; +use ZfcUser\EventManager\EventProvider; -class Password +class Password extends EventProvider { /** * @var ModelMapper @@ -78,11 +79,12 @@ public function sendForgotEmailMessage($to, $model) { $mailService = $this->mailservice; + $resetExpire = $this->getOptions()->getResetExpire(); $from = $this->getOptions()->getEmailFromAddress(); $subject = $this->getOptions()->getResetEmailSubjectLine(); $template = $this->getOptions()->getResetEmailTemplate(); - $message = $mailService->createTextMessage($from, $to, $subject, $template, array('record' => $model)); + $message = $mailService->createHtmlMessage($from, $to, $subject, $template, ['record' => $model, 'userEmail' => $to, 'resetExpire' => $resetExpire]); $mailService->send($message); } @@ -98,6 +100,8 @@ public function resetPassword($password, $user, array $data) $user->setPassword($pass); $this->getUserMapper()->update($user); + // trigger reset password event + $this->getEventManager()->trigger(__FUNCTION__, $this, ['user' => $user]); $this->remove($password); return true; From e89a06afbf0bda8563750aab1281f4b81440e47a Mon Sep 17 00:00:00 2001 From: APaikens Date: Wed, 25 Jun 2025 14:33:54 +0300 Subject: [PATCH 30/33] Switch to divi-mail mailservice --- composer.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c9d4929..e936d5d 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,15 @@ "zfcuser" ], "homepage": "https://github.com/goalio/GoalioForgotPassword", + "repositories": [ + { + "type": "vcs", + "url": "git@gitlab.di.lv:DIVI/divi-mail.git", + "trunk-path": "trunk", + "branches-path": "branches", + "tags-path": "tags" + } + ], "authors": [ { "name": "Philipp Dobrigkeit", @@ -16,7 +25,7 @@ } ], "require": { - "goalio/goalio-mailservice": "^3.0", + "divi/divi-mail": "^1.0" "zf-commons/zfc-user": "4.*" }, "autoload": { From dba653570893277e02c10dcc16ca0eb596f8e259 Mon Sep 17 00:00:00 2001 From: APaikens Date: Thu, 26 Jun 2025 09:02:32 +0300 Subject: [PATCH 31/33] Update composer.json - fix typo --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e936d5d..d920cb9 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ } ], "require": { - "divi/divi-mail": "^1.0" + "divi/divi-mail": "^1.0", "zf-commons/zfc-user": "4.*" }, "autoload": { From 6e991a6f0145f98c4d1b9b84b73f1f731741dca9 Mon Sep 17 00:00:00 2001 From: APaikens Date: Mon, 22 Dec 2025 09:44:39 +0200 Subject: [PATCH 32/33] ResetFactory, Add user form filter settings from db, if there is set some --- .../Form/Service/ResetFactory.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/GoalioForgotPassword/Form/Service/ResetFactory.php b/src/GoalioForgotPassword/Form/Service/ResetFactory.php index 578b030..e3fbb94 100644 --- a/src/GoalioForgotPassword/Form/Service/ResetFactory.php +++ b/src/GoalioForgotPassword/Form/Service/ResetFactory.php @@ -1,6 +1,7 @@ get('goalioforgotpassword_module_options'); $config = $container->get('config'); $form = new Reset(null, $options); + + $additionalConfig = $config['zfcuser']; + $siteConfigService = null; + + $configForFilter = []; + $configForFilter['minPasswordLength'] = 6; + if(isset($config['zfcuser']['minPasswordLength'])){ + $configForFilter['minPasswordLength'] = $config['zfcuser']['minPasswordLength']; + } + + if ($container->has(SiteConfigService::class)) { + $additionalConfig = $container->get(SiteConfigService::class); + $configForFilter['minPasswordLength'] = $siteConfigService->get('minPasswordLength'); + } $form->setInputFilter(new ResetFilter($options, new PasswordIsValid( $container->get('zfcuser_module_options'), - $config['zfcuser'] + $additionalConfig ), - $config['zfcuser'], + $configForFilter, )); return $form; } From 736d586eef0aaea9f8ce50de1142d8b0599bebff Mon Sep 17 00:00:00 2001 From: APaikens Date: Mon, 22 Dec 2025 09:59:26 +0200 Subject: [PATCH 33/33] Update ResetFactory.php, typo fix --- src/GoalioForgotPassword/Form/Service/ResetFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GoalioForgotPassword/Form/Service/ResetFactory.php b/src/GoalioForgotPassword/Form/Service/ResetFactory.php index e3fbb94..df21c3b 100644 --- a/src/GoalioForgotPassword/Form/Service/ResetFactory.php +++ b/src/GoalioForgotPassword/Form/Service/ResetFactory.php @@ -26,7 +26,7 @@ public function __invoke(\Interop\Container\ContainerInterface $container, $requ if ($container->has(SiteConfigService::class)) { $additionalConfig = $container->get(SiteConfigService::class); - $configForFilter['minPasswordLength'] = $siteConfigService->get('minPasswordLength'); + $configForFilter['minPasswordLength'] = $additionalConfig->get('minPasswordLength'); } $form->setInputFilter(new ResetFilter($options, new PasswordIsValid(