From 021a003ab334d8f57c1aea1fe9779bcf2579cf11 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 17 Apr 2024 13:09:38 +0530 Subject: [PATCH 1/2] Updated error message for guest account to customer account transformation --- controllers/front/GuestTrackingController.php | 9 +++++++-- controllers/front/OrderOpcController.php | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index ab05a2876..ad2a0cb29 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -95,8 +95,13 @@ class GuestTrackingControllerCore extends FrontController } elseif (!Tools::getValue('password')) { $this->errors[] = Tools::displayError('Invalid password.'); } elseif (!$customer->transformToCustomer($this->context->language->id, Tools::getValue('password'))) { - // @todo clarify error message - $this->errors[] = Tools::displayError('An error occurred while transforming a guest into a registered customer.'); + if (!$customer->isGuest()) { + $this->errors[] = Tools::displayError('This account is already registered as a customer.'); + }else if (!Validate::isPasswd(Tools::getValue('password'))) { + $this->errors[] = Tools::displayError('Invalid password.'); + } else { + $this->errors[] = Tools::displayError('An error occurred while transforming a guest into a registered customer.'); + } } else { $this->context->smarty->assign('transformSuccess', true); } diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index 465c6a7ca..e109721a6 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -176,7 +176,13 @@ class OrderOpcControllerCore extends ParentOrderController if ($customer->transformToCustomer($this->context->language->id, $passwd)) { $this->context->updateCustomer($customer); } else { - $this->errors[] = Tools::displayError('An error occurred while transforming your account into a registered customer.'); + if (!$customer->isGuest()) { + $this->errors[] = Tools::displayError('This account is already registered as a customer.'); + }else if (!Validate::isPasswd($passwd)) { + $this->errors[] = Tools::displayError('Invalid password.'); + } else { + $this->errors[] = Tools::displayError('An error occurred while transforming your account into a registered customer.'); + } } } From 80f0e1758b442ac0558e8e78c82b5080f9e71b65 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Mon, 29 Apr 2024 18:30:40 +0530 Subject: [PATCH 2/2] Removed: no required and dulicate validations --- controllers/front/GuestTrackingController.php | 12 ++++-------- controllers/front/OrderOpcController.php | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index ad2a0cb29..e7017e12f 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -92,16 +92,12 @@ class GuestTrackingControllerCore extends FrontController $customer = new Customer((int)$order->id_customer); if (!Validate::isLoadedObject($customer)) { $this->errors[] = Tools::displayError('Invalid customer'); - } elseif (!Tools::getValue('password')) { + } elseif (!Tools::getValue('password') + || !Validate::isPasswd(Tools::getValue('password') + )) { $this->errors[] = Tools::displayError('Invalid password.'); } elseif (!$customer->transformToCustomer($this->context->language->id, Tools::getValue('password'))) { - if (!$customer->isGuest()) { - $this->errors[] = Tools::displayError('This account is already registered as a customer.'); - }else if (!Validate::isPasswd(Tools::getValue('password'))) { - $this->errors[] = Tools::displayError('Invalid password.'); - } else { - $this->errors[] = Tools::displayError('An error occurred while transforming a guest into a registered customer.'); - } + $this->errors[] = Tools::displayError('An error occurred while transforming a guest into a registered customer.'); } else { $this->context->smarty->assign('transformSuccess', true); } diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index e109721a6..2cd2a223c 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -173,16 +173,12 @@ class OrderOpcControllerCore extends ParentOrderController if (!count($this->errors)) { $customer = new Customer($this->context->customer->id); - if ($customer->transformToCustomer($this->context->language->id, $passwd)) { + if (!$customer->isGuest()) { + $this->errors[] = Tools::displayError('This account is already registered as a customer.'); + } else if ($customer->transformToCustomer($this->context->language->id, $passwd)) { $this->context->updateCustomer($customer); } else { - if (!$customer->isGuest()) { - $this->errors[] = Tools::displayError('This account is already registered as a customer.'); - }else if (!Validate::isPasswd($passwd)) { - $this->errors[] = Tools::displayError('Invalid password.'); - } else { - $this->errors[] = Tools::displayError('An error occurred while transforming your account into a registered customer.'); - } + $this->errors[] = Tools::displayError('An error occurred while transforming your account into a registered customer.'); } }