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; // override activated to true, if it is a reviewer card if (isset($idCard)) { $card = Card::findOne($idCard); if (isset($card)) { if (isset($card->type)) { if ( Card::TYPE_REVIEW === $card->type){ $activated = true; } } } } } // if device is not activated, throw exception with http status 412 if ($activated === false) { throw new HttpException( HttpStatus::PRECONDITION_FAILED,"Device is not activated: " . $deviceId); } } catch (HttpException $e) { if ($e->statusCode === HttpStatus::PRECONDITION_FAILED && $this->isOptional($action)) { return true; } throw $e; } return true; } /** * Checks, whether authentication is optional for the given action. * * @param Action $action action to be checked. * @return bool whether authentication is optional or not. * @see optional * @since 2.0.7 */ protected function isOptional($action) { $id = $this->getActionId($action); foreach ($this->optional as $pattern) { if (StringHelper::matchWildcard($pattern, $id)) { return true; } } return false; } }