|
|
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace App\State\Processor;
|
|
|
|
|
|
+use AltchaOrg\Altcha\Altcha;
|
|
|
use ApiPlatform\Metadata\Operation;
|
|
|
use ApiPlatform\Metadata\Post;
|
|
|
use ApiPlatform\State\ProcessorInterface;
|
|
|
@@ -18,6 +19,7 @@ class ContactRequestProcessor implements ProcessorInterface
|
|
|
private readonly MailerInterface $symfonyMailer,
|
|
|
private readonly string $fromEmail,
|
|
|
private readonly string $contactEmail,
|
|
|
+ private readonly string $hmacKey
|
|
|
)
|
|
|
{}
|
|
|
|
|
|
@@ -33,6 +35,16 @@ class ContactRequestProcessor implements ProcessorInterface
|
|
|
/** @var ContactRequest $contactRequest */
|
|
|
$contactRequest = $data;
|
|
|
|
|
|
+ $valid = Altcha::verifySolution(
|
|
|
+ $contactRequest->getAltchaPayload(),
|
|
|
+ $this->hmacKey,
|
|
|
+ true
|
|
|
+ );
|
|
|
+
|
|
|
+ if (!$valid) {
|
|
|
+ throw new \RuntimeException('Invalid payload');
|
|
|
+ }
|
|
|
+
|
|
|
$symfonyMail = (new Email())
|
|
|
->to($this->contactEmail)
|
|
|
->from($this->fromEmail)
|