doorlogmanager view: show human readable errorcodes; DoorManagerLogController.php authorization fix
This commit is contained in:
@@ -98,7 +98,12 @@ class DoorManager extends BaseObject
|
||||
$direction = DoorLog::$DIRECTION_OUT;
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestHttpException("$requestId: Direction not supported: " . $direction);
|
||||
throw new FitnessException(
|
||||
"Direction $direction not supported",
|
||||
FitnessException::TYPE_BAD_REQUEST,
|
||||
"INVALID_DIRECTION",
|
||||
$context
|
||||
);
|
||||
}
|
||||
$context->direction = $direction;
|
||||
|
||||
@@ -108,18 +113,24 @@ class DoorManager extends BaseObject
|
||||
$virtualKey = VirtualKey::findOne(['number' => $identifier]);
|
||||
|
||||
if (!isset($virtualKey)) {
|
||||
$context->error = true;
|
||||
$context->errorCode = "VIRTUAL_KEY_NOT_FOUND";
|
||||
throw new BadRequestHttpException("$requestId: Virtual key not found: " . $identifier);
|
||||
throw new FitnessException(
|
||||
"Virtual Key Not Found",
|
||||
FitnessException::TYPE_BAD_REQUEST,
|
||||
"VIRTUAL_KEY_NOT_FOUND",
|
||||
$context
|
||||
);
|
||||
}
|
||||
$card = Card::findOne($virtualKey->id_card);
|
||||
if ($card != null) {
|
||||
$card = Card::readCard($card->number);
|
||||
}
|
||||
if ($card == null) {
|
||||
$context->error = true;
|
||||
$context->errorCode = "CARD_NOT_FOUND";
|
||||
throw new BadRequestHttpException("$requestId: Card not found by virtual key: " . $identifier . '/' . $virtualKey->id_card);
|
||||
throw new FitnessException(
|
||||
"Virtual Key Not Found",
|
||||
FitnessException::TYPE_BAD_REQUEST,
|
||||
"CARD_FOR_VIRTUAL_KEY_NOT_FOUND",
|
||||
$context
|
||||
);
|
||||
}
|
||||
$cardNumber = $card->number;
|
||||
\Yii::info("$requestId: virtual key and card loaded in sec " . $stopWatch->split());
|
||||
@@ -128,9 +139,12 @@ class DoorManager extends BaseObject
|
||||
$card = Card::readCard(Helper::fixAsciiChars($identifier));
|
||||
\Yii::info("$requestId: Card loaded in sec " . $stopWatch->split());
|
||||
if (!isset($card)) {
|
||||
$context->error = true;
|
||||
$context->errorCode = "CARD_NOT_FOUND";
|
||||
throw new BadRequestHttpException("$requestId: Card not found with number: " . $identifier);
|
||||
throw new FitnessException(
|
||||
"Virtual Key Not Found",
|
||||
FitnessException::TYPE_BAD_REQUEST,
|
||||
"CARD_NOT_FOUND",
|
||||
$context
|
||||
);
|
||||
}
|
||||
\Yii::info("$requestId: card loaded in sec " . $stopWatch->split());
|
||||
$virtualKey = VirtualKey::findOne(['id_card' => $card->id_card]);
|
||||
|
||||
Reference in New Issue
Block a user