user->getIdentity(); if (isset($customer)) { $idCard = $customer->id_customer_card; // find out if the device is activated $mobileDeviceManager = new MobileDeviceManager(); $activated = $mobileDeviceManager->isMobileDeviceActivatedByIdCard($idCard); } // if device is not activated, throw exception with http status 412 if ($activated === false) { throw new HttpException( HttpStatus::PRECONDITION_FAILED,"Card not activated"); } } 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; } }