Fix register for migration. #591
This commit is contained in:
parent
1d4a52bbf2
commit
35b228ef0c
5 changed files with 29 additions and 18 deletions
|
|
@ -67,3 +67,9 @@ access_keys:
|
||||||
acls:
|
acls:
|
||||||
- id: dealer.list
|
- id: dealer.list
|
||||||
label: List
|
label: List
|
||||||
|
|
||||||
|
- id: mobile_customer
|
||||||
|
label: Mobile Customer
|
||||||
|
acls:
|
||||||
|
- id: mobile_customer.register
|
||||||
|
label: Register Mobile Customer
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,14 @@ security:
|
||||||
provider: api_key_user_provider
|
provider: api_key_user_provider
|
||||||
user_checker: Catalyst\AuthBundle\Service\UserChecker
|
user_checker: Catalyst\AuthBundle\Service\UserChecker
|
||||||
|
|
||||||
|
mobile_api:
|
||||||
|
pattern: ^\/resqapi\/
|
||||||
|
stateless: true
|
||||||
|
simple_preauth:
|
||||||
|
authenticator: Catalyst\APIBundle\Security\APIKeyAuthenticator
|
||||||
|
provider: api_key_user_provider
|
||||||
|
user_checker: Catalyst\AuthBundle\Service\UserChecker
|
||||||
|
|
||||||
main:
|
main:
|
||||||
provider: user_provider
|
provider: user_provider
|
||||||
form_login:
|
form_login:
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,7 @@ use Doctrine\ORM\Query;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
use Catalyst\APIBundle\Controller\APIController;
|
use Catalyst\APIBundle\Controller\APIController;
|
||||||
// TODO: what do we use for response? APIResponse or APIResult?
|
|
||||||
// APIResult is what is used by APIController. APIResponse is what is used by CAPI
|
|
||||||
use Catalyst\APIBundle\Response\APIResponse;
|
use Catalyst\APIBundle\Response\APIResponse;
|
||||||
use App\Ramcar\APIResult;
|
|
||||||
|
|
||||||
use App\Entity\MobileUser;
|
use App\Entity\MobileUser;
|
||||||
|
|
||||||
|
|
@ -33,8 +30,6 @@ class CustomerController extends APIController
|
||||||
public function register(Request $req, EntityManagerInterface $em)
|
public function register(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
// no need for access for register
|
// no need for access for register
|
||||||
|
|
||||||
$res = new APIResult();
|
|
||||||
// confirm parameters
|
// confirm parameters
|
||||||
$required_params = [
|
$required_params = [
|
||||||
'phone_model',
|
'phone_model',
|
||||||
|
|
@ -43,17 +38,12 @@ class CustomerController extends APIController
|
||||||
'phone_id'
|
'phone_id'
|
||||||
];
|
];
|
||||||
|
|
||||||
// TODO: APIController has a function called checkRequiredParameters that does the same thing
|
$msg = $this->checkRequiredParameters($req, $required_params);
|
||||||
// as checkMissingParameters. Maybe we can use that?
|
if ($msg)
|
||||||
$missing = $this->checkMissingParameters($req, $required_params);
|
return new APIResponse(false, $error_message);
|
||||||
if (count($missing) > 0)
|
|
||||||
{
|
|
||||||
$params = implode(', ', $missing);
|
|
||||||
$res->setError(true)
|
|
||||||
->setErrorMessage('Missing parameter(s): ' . $params);
|
|
||||||
return $res->getReturnResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// get capi user to link to mobile user
|
||||||
|
$user_id = $this->getUser()->getID();
|
||||||
// retry until we get a unique id
|
// retry until we get a unique id
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
@ -64,7 +54,8 @@ class CustomerController extends APIController
|
||||||
$mobile_user->setPhoneModel($req->request->get('phone_model'))
|
$mobile_user->setPhoneModel($req->request->get('phone_model'))
|
||||||
->setOSType($req->request->get('os_type'))
|
->setOSType($req->request->get('os_type'))
|
||||||
->setOSVersion($req->request->get('os_version'))
|
->setOSVersion($req->request->get('os_version'))
|
||||||
->setPhoneID($req->request->get('phone_id'));
|
->setPhoneID($req->request->get('phone_id'))
|
||||||
|
->setCapiUserId($user_id);
|
||||||
|
|
||||||
// reopen in case we get an exception
|
// reopen in case we get an exception
|
||||||
if (!$em->isOpen())
|
if (!$em->isOpen())
|
||||||
|
|
@ -99,7 +90,7 @@ class CustomerController extends APIController
|
||||||
];
|
];
|
||||||
|
|
||||||
// response
|
// response
|
||||||
return $res->getReturnResponse();
|
return new APIResponse(true, 'Mobile user created.', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function confirmNumber(RisingTideGateway $rt, Request $req, EntityManagerInterface $em)
|
public function confirmNumber(RisingTideGateway $rt, Request $req, EntityManagerInterface $em)
|
||||||
|
|
|
||||||
|
|
@ -1196,7 +1196,7 @@ class JobOrderController extends APIController
|
||||||
|
|
||||||
$invoice = $jo->getInvoice();
|
$invoice = $jo->getInvoice();
|
||||||
|
|
||||||
/ make invoice json data
|
// make invoice json data
|
||||||
$data = [
|
$data = [
|
||||||
'total_price' => (float) $invoice->getTotalPrice(),
|
'total_price' => (float) $invoice->getTotalPrice(),
|
||||||
'vat_ex_price' => (float) $invoice->getVATExclusivePrice(),
|
'vat_ex_price' => (float) $invoice->getVATExclusivePrice(),
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,12 @@ class MobileUser
|
||||||
return $this->os_type;
|
return $this->os_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setOSVersion($version)
|
||||||
|
{
|
||||||
|
$this->os_version = $version;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getOSVersion()
|
public function getOSVersion()
|
||||||
{
|
{
|
||||||
return $this->os_version;
|
return $this->os_version;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue