use mobiledevice as login object for mobile api
This commit is contained in:
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace mobileapi\manager;
|
||||
|
||||
use Exception;
|
||||
use Yii;
|
||||
use common\models\Card;
|
||||
use common\models\CardKeyAssignment;
|
||||
use common\models\Customer;
|
||||
use common\models\Key;
|
||||
use common\models\Ticket;
|
||||
use Endroid\QrCode\QrCode;
|
||||
@@ -11,17 +14,27 @@ use yii\web\NotFoundHttpException;
|
||||
|
||||
class ApiManager
|
||||
{
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function getCardPage()
|
||||
{
|
||||
$customer = \Yii::$app->user->getIdentity();
|
||||
$device = Yii::$app->user->getIdentity();
|
||||
|
||||
if (!isset($customer)) {
|
||||
throw new \yii\web\NotFoundHttpException();
|
||||
if (!isset($device)) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$card = Card::findOne($customer->id_customer_card);
|
||||
$card = Card::findOne($device->id_card);
|
||||
|
||||
if (!isset($card)) {
|
||||
throw new \yii\web\NotFoundHttpException();
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
$customer = Customer::findOne(['id_customer_card' => $device->id_card]);
|
||||
|
||||
if (!isset($customer)) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
$qrCode = new QrCode($card->number);
|
||||
@@ -34,17 +47,17 @@ class ApiManager
|
||||
|
||||
}
|
||||
|
||||
function getTicketPage()
|
||||
public function getTicketPage()
|
||||
{
|
||||
$customer = \Yii::$app->user->getIdentity();
|
||||
$device = Yii::$app->user->getIdentity();
|
||||
|
||||
if (!isset($customer)) {
|
||||
throw new \yii\web\NotFoundHttpException();
|
||||
if (!isset($device)) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$card = Card::findOne($customer->id_customer_card);
|
||||
$card = Card::findOne($device->id_card);
|
||||
|
||||
if (!isset($card)) {
|
||||
throw new \yii\web\NotFoundHttpException();
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$tickets = Ticket::readActive($card);
|
||||
|
||||
@@ -68,15 +81,15 @@ class ApiManager
|
||||
|
||||
public function getVirtualKeyPage()
|
||||
{
|
||||
$customer = \Yii::$app->user->getIdentity();
|
||||
$device = Yii::$app->user->getIdentity();
|
||||
|
||||
if (!isset($customer)) {
|
||||
throw new \yii\web\NotFoundHttpException();
|
||||
if (!isset($device)) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$card = Card::findOne($customer->id_customer_card);
|
||||
$card = Card::findOne($device->id_card);
|
||||
|
||||
if (!isset($card)) {
|
||||
throw new \yii\web\NotFoundHttpException();
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
$keyObject = null;
|
||||
@@ -101,9 +114,9 @@ class ApiManager
|
||||
'key' => $key->number,
|
||||
'idKey' => $key->id_key
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
// failed to get key
|
||||
\Yii::error('Failed to get virtual key: ' . $e->getMessage());
|
||||
Yii::error('Failed to get virtual key: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user