Skip to content

Commit

Permalink
Some checks for validator
Browse files Browse the repository at this point in the history
  • Loading branch information
Huluti committed Nov 24, 2024
1 parent 7f4d8ed commit a9c7f4b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Validator/AltchaValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,19 @@ public function validate($value, Constraint $constraint): void

$request = $this->requestStack->getCurrentRequest();
$altchaEncoded = $request->request->get('altcha');
if (!is_string($altchaEncoded)) {
$this->context->buildViolation($constraint->message)
->addviolation();
return;
}
$altchaJson = base64_decode($altchaEncoded, true);
if (!is_string($altchaJson)) {
$this->context->buildViolation($constraint->message)
->addviolation();
return;
}
$payload = json_decode($altchaJson, true);

// TODO: verify each line above

if (!Altcha::verifySolution($payload, $this->hmacKey, true)) {
$this->context->buildViolation($constraint->message)
->addviolation();
Expand Down

0 comments on commit a9c7f4b

Please sign in to comment.