diff --git a/src/Controller/CustomerAppAPI/AuthController.php b/src/Controller/CustomerAppAPI/AuthController.php index 51fe4092..64dc3b4a 100644 --- a/src/Controller/CustomerAppAPI/AuthController.php +++ b/src/Controller/CustomerAppAPI/AuthController.php @@ -156,6 +156,7 @@ class AuthController extends ApiController // TODO: check if we have the number registered before and merge $dupe_sess = $this->findNumberSession($this->session->getPhoneNumber()); if ($dupe_sess != null) { + error_log("Found existing customer session for " . $this->session->getPhoneNumber()); $dupe_cust = $dupe_sess->getCustomer(); $this->session->setCustomer($dupe_cust); @@ -173,17 +174,20 @@ class AuthController extends ApiController if (!$customer_user) { $customer_user = $this->findCustomerUserByNumber($this->session->getPhoneNumber()); - if ($customer_user != null) { - // dupe_cust_user is the same as the customer we found? - $this->session->setCustomerUser($customer_user); - } else { + + if ($customer_user === null) { + error_log("Creating a new customer user for " . $this->session->getPhoneNumber()); $customer_user = new CustomerUser(); $customer_user->setCustomer($this->session->getCustomer()) ->setPhoneNumber($this->session->getPhoneNumber()); // save $this->em->persist($customer_user); + } else { + error_log("Found existing customer user for " . $this->session->getPhoneNumber()); } + + $this->session->setCustomerUser($customer_user); } $this->em->flush();