Compare commits

..

1 Commits

Author SHA1 Message Date
633e93c129 feat(altcha): add altcha validation layer to login
Some checks reported warnings
Cadoles/hydra-sql/pipeline/pr-develop This commit is unstable
2025-04-02 16:30:45 +02:00
2 changed files with 7 additions and 2 deletions

View File

@ -2,9 +2,11 @@
namespace App\Flag\Controller;
use App\Flag\FlagAccessor;
use App\Flag\FlagEnum;
use Predis\ClientInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Exception\JsonException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ -17,12 +19,13 @@ class FlagController extends AbstractController
{
try {
FlagEnum::from($flagName);
$flagValue = \json_decode($request->getContent(), true, flags: JSON_THROW_ON_ERROR)[FlagAccessor::FLAG_VALUE];
} catch (\ValueError $e) {
throw new \InvalidArgumentException('invalid flag name provided');
} catch (JsonException $e) {
throw new \InvalidArgumentException('invalid json format');
}
$flagValue = $request->query->getBoolean('flagValue');
$redis->set($flagName, $flagValue);
return new JsonResponse(

View File

@ -6,6 +6,8 @@ use Predis\ClientInterface;
class FlagAccessor
{
public const FLAG_VALUE = 'flagValue';
public function __construct(
private readonly ClientInterface $redis
) {