add cors filter for mobileapi
This commit is contained in:
@@ -31,15 +31,16 @@ class ActivatedFilter extends ActionFilter
|
||||
// get the device
|
||||
/** @var MobileDevice $mobileDevice */
|
||||
$mobileDevice = \Yii::$app->user->getIdentity();
|
||||
$deviceId = null;
|
||||
if (isset($mobileDevice)) {
|
||||
$deviceId = $mobileDevice->id;
|
||||
$idCard = $mobileDevice->id_card;
|
||||
// find out if the device is activated
|
||||
$activated = $mobileDevice->status === MobileDevice::STATUS_ACTIVE;
|
||||
}
|
||||
|
||||
// if device is not activated, throw exception with http status 412
|
||||
if ($activated === false) {
|
||||
throw new HttpException( HttpStatus::PRECONDITION_FAILED,"Device is not activated: " . $mobileDevice->id);
|
||||
throw new HttpException( HttpStatus::PRECONDITION_FAILED,"Device is not activated: " . $deviceId);
|
||||
}
|
||||
} catch (HttpException $e) {
|
||||
if ($e->statusCode === HttpStatus::PRECONDITION_FAILED && $this->isOptional($action)) {
|
||||
|
||||
Reference in New Issue
Block a user