feat(altcha): add altcha validation layer to login
Some checks reported warnings
Cadoles/hydra-sql/pipeline/pr-develop This commit is unstable

This commit is contained in:
2025-03-24 17:20:17 +01:00
parent 1cb5ae6bc3
commit 3c06f6e09e
51 changed files with 1750 additions and 492 deletions

View File

@ -0,0 +1,48 @@
<?php
namespace App\Altcha;
use App\Altcha\Form\AltchaModel;
use Symfony\Component\Form\DataTransformerInterface;
class AltchaTransformer implements DataTransformerInterface
{
/**
* {@inheritDoc}
*/
public function reverseTransform($value): AltchaModel
{
if (empty($value)) {
return new AltchaModel();
}
$decodedValue = base64_decode($value);
$data = json_decode($decodedValue);
$model = new AltchaModel();
foreach ($data as $property => $value) {
$model->{$property} = $value;
}
return $model;
}
/**
* {@inheritDoc}
*/
public function transform($value): string
{
if (empty($value)) {
return '';
}
$json = json_encode($value);
if (false === $json) {
return '';
}
return base64_encode($json);
}
}