Fix existing customer user association #730
This commit is contained in:
parent
e3be92b63e
commit
81d4f46930
1 changed files with 8 additions and 4 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue