Compare commits

..

1 Commits

Author SHA1 Message Date
934eefa802 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 15:04:29 +02:00
2 changed files with 2 additions and 7 deletions

View File

@ -2,11 +2,9 @@
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;
@ -19,13 +17,12 @@ 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,8 +6,6 @@ use Predis\ClientInterface;
class FlagAccessor
{
public const FLAG_VALUE = 'flagValue';
public function __construct(
private readonly ClientInterface $redis
) {