Add mobile api resend code #130
This commit is contained in:
parent
0374679bc4
commit
7d3873022e
3 changed files with 58 additions and 0 deletions
|
|
@ -104,3 +104,13 @@ api_device_id:
|
||||||
path: /api/device_id
|
path: /api/device_id
|
||||||
controller: App\Controller\APIController:updateDeviceID
|
controller: App\Controller\APIController:updateDeviceID
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|
||||||
|
api_privacy:
|
||||||
|
path: /api/privacy
|
||||||
|
controller: App\Controller\APIController:privacySettings
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
api_resend_code:
|
||||||
|
path: /api/resend_code
|
||||||
|
controller: App\Controller\APIController:resendCode
|
||||||
|
methods: [POST]
|
||||||
|
|
|
||||||
|
|
@ -1398,4 +1398,34 @@ class APIController extends Controller
|
||||||
// response
|
// response
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function resendCode(Request $req)
|
||||||
|
{
|
||||||
|
$required_params = [];
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||||
|
if ($res->isError())
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
|
||||||
|
// already confirmed
|
||||||
|
if ($this->session->isConfirmed())
|
||||||
|
{
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage('User is already confirmed.');
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
// have sent code before
|
||||||
|
if ($this->session->getDateCodeSent() != null)
|
||||||
|
{
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage('Can only send confirm code every 5 mins.');
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: send via sms
|
||||||
|
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,12 @@ class MobileSession
|
||||||
*/
|
*/
|
||||||
protected $date_confirmed;
|
protected $date_confirmed;
|
||||||
|
|
||||||
|
// date and time that the confirmation code was last sent
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="datetime", nullable=true)
|
||||||
|
*/
|
||||||
|
protected $date_code_sent;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
@ -88,6 +94,7 @@ class MobileSession
|
||||||
$this->customer = null;
|
$this->customer = null;
|
||||||
$this->confirm_flag = false;
|
$this->confirm_flag = false;
|
||||||
$this->date_confirmed = null;
|
$this->date_confirmed = null;
|
||||||
|
$this->date_code_sent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateKeyID()
|
public function generateKeyID()
|
||||||
|
|
@ -204,4 +211,15 @@ class MobileSession
|
||||||
{
|
{
|
||||||
return $this->date_confirmed;
|
return $this->date_confirmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setDateCodeSent(DateTime $date)
|
||||||
|
{
|
||||||
|
$this->date_code_sent = $date;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDateCodeSent()
|
||||||
|
{
|
||||||
|
return $this->date_code_sent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue