Merge branch '116-add-relogin-feature-to-mobile-app-api-2' into 'master'
Resolve "Add relogin feature to mobile app api" Closes #116 See merge request jankstudio/resq!100
This commit is contained in:
commit
c8c6424251
1 changed files with 28 additions and 1 deletions
|
|
@ -218,12 +218,29 @@ class APIController extends Controller
|
||||||
->setPhoneNumber($phone_number);
|
->setPhoneNumber($phone_number);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// TODO: send sms to number
|
// TODO: send sms with validation code to number
|
||||||
|
|
||||||
// response
|
// response
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: find session customer by phone number
|
||||||
|
protected function findNumberSession($number)
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$query = $em->getRepository(MobileSession::class)->createQueryBuilder('s')
|
||||||
|
->where('s.phone_number = :number')
|
||||||
|
->andWhere('s.customer is not null')
|
||||||
|
->andWhere('s.confirm_flag = 1')
|
||||||
|
->setParameter('number', $number)
|
||||||
|
->getQuery();
|
||||||
|
|
||||||
|
// we just need one
|
||||||
|
$res = $query->getOneOrNullResult();
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
public function validateCode(Request $req)
|
public function validateCode(Request $req)
|
||||||
{
|
{
|
||||||
// check parameters
|
// check parameters
|
||||||
|
|
@ -250,6 +267,16 @@ class APIController extends Controller
|
||||||
$date = new DateTime();
|
$date = new DateTime();
|
||||||
$this->session->setDateConfirmed($date)
|
$this->session->setDateConfirmed($date)
|
||||||
->setConfirmed();
|
->setConfirmed();
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: check if we have the number registered before and merge
|
||||||
|
$dupe_sess = $this->findNumberSession($this->session->getPhoneNumber());
|
||||||
|
if ($dupe_sess != null)
|
||||||
|
{
|
||||||
|
$dupe_cust = $dupe_sess->getCustomer();
|
||||||
|
$this->session->setCustomer($dupe_cust);
|
||||||
|
}
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// response
|
// response
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue