feat: add HTTP 451 error code if needed

This commit is contained in:
Maël Gangloff
2024-08-06 22:11:57 +02:00
parent e393bcf0af
commit 504e609579
2 changed files with 14 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Config\Connector;
use App\Entity\Domain;
use Ovh\Api;
use Symfony\Component\HttpKernel\Exception\HttpException;
readonly class OvhConnector implements ConnectorInterface
{
@@ -136,14 +137,16 @@ readonly class OvhConnector implements ConnectorInterface
|| !is_string($apiEndpoint) || empty($apiEndpoint)
|| !is_string($ovhSubsidiary) || empty($ovhSubsidiary)
|| !is_string($pricingMode) || empty($pricingMode)
|| true !== $acceptConditions
|| true !== $ownerLegalAge
|| true !== $waiveRetractationPeriod
) {
throw new \Exception('Bad authData schema');
}
if (true !== $acceptConditions
|| true !== $ownerLegalAge
|| true !== $waiveRetractationPeriod) {
throw new HttpException(451, 'The user has not given explicit consent', null, ['Link' => '<https://www.ovhcloud.com/fr/terms-and-conditions/contracts/>; rel="blocked-by"']);
}
$conn = new Api(
$appKey,
$appSecret,