karser / KarserRecaptcha3Bundle

Google ReCAPTCHA v3 for Symfony

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The captcha value is missing

BarsikCat opened this issue · comments

Hello,

I'm continually getting "The captcha value is missing" message.

This is my first PHP project for more than a decade :)

The browser says that the form is successfully posted:

Form data:

contact_us[captcha]: 
03AGdBq26czW2_CFHbLvnvfy-qrzIYWMr1drr1WhcEyjJrElxSTHpG1MepvjeZF8Yafd2guBXZ9bbAMbSjdOJnli0RleE2f7rtht9-iRtKwxFqzn4tGn7ReDYesItAv8OvgbR7lF3Zw6o8IJG0QZlSL_aZrywQVfXUZ9TCsBYG0gDeW-X-ymG97XqgXbHX43bTe6oOmel5wNk94W2FTtiXgVxR0TLdG5QRnMVXPL06Cu6Y-TMEd5KH0hrADiSnZG7EZaTQSJNiVcDEB9WSX-rcnacgiHzkIgLVs9f6NrDpmS2lBpl1Lv6OCaYg0Jz1EFJx_fr2s_fP2vltuOWHOHojyWjdC30rJySUZ_35Yvslh4A8TmiNfGDn7bRlO2c990GVB9f5VINTa9yn1Zb6dAcZxDlFXrWg83Q5gV9wSL5y6ACALvrdi1IwvyqhDiK2TDydwxm741VMvttN
contact_us[_token]:
9af332ff29b1fead7c8a058.VhAT8CLqFjeAw7lsC2tQ_gKLAhNUODTRuizgDsU_HuA.LCMipHK4Z3i5p_obbj0XjDfUXVwGdXi76xuCfqZUf9MsPWCBRb9mR62FjQ

But debug details look strange for me:
debug

I can share the entire project :)

Hello, that's weird. Can you show how you create Recaptcha3Type, please?

Also, try going through the troubleshooting checklist. I'm sure there is some misconfiguration issue

Thanks for the reply!

I can easily misconfigure something because I am back to PHP after a long period of time. It looks pretty different for me :)

class ContactUsType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('name', TextType::class, [
                'label' => "Your name:",
                'required' => false
            ])
            ->add('email', EmailType::class, [
                'label' => "Your email address:",
                'help' => "We'll never share your email with anyone else.",
                'required' => false
            ])
            ->add('message', TextareaType::class, [
                'label' => "Your message:",
                'attr' => ['rows' => '7'],
            ])
            ->add('send', SubmitType::class, [
                'label' => "Send Message",
            ])
            ->add('captcha', Recaptcha3Type::class, [
                'constraints' => new Recaptcha3(),
                'action_name' => 'contacts',
                //'script_nonce_csp' => $nonceCSP,
            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => ContactUs::class,
        ]);
    }
}
namespace App\Entity;

class ContactUs
{
    public string $captcha;

    protected string $name;
    protected string $email;
    protected string $message;

    public function getName(): string
    {
        return $this->name;
    }

    public function setName(string $name): void
    {
        $this->name = $name;
    }

    public function getEmail(): string
    {
        return $this->email;
    }

    public function setEmail(string $email): void
    {
        $this->email = $email;
    }

    public function getMessage(): string
    {
        return $this->message;
    }

    public function setMessage(string $message): void
    {
        $this->message = $message;
    }

}

In your "the troubleshooting checklist" the Captcha setup picture is truncated. I have 3 checkboxes bellow. They are translated to my language but mean the following: Check reCAPTCHA solution source - Yes, Allow AMP-page - No, Report to owner - Yes

More pictures for you:
truble

truble2

truble3

It is uploaded to a test domain and I can share GitHub repository with you.

All looks good. Please, share the repo

Invite sent. Complete newbie (in modern PHP) form processing realization made from current Symfony documentation.

Figured it out. You don't need $captcha property on ContactUs entity because Recaptcha3Type is not mapped
That's what you need to do to make it work:
Screenshot from 2021-10-15 13-16-18
Screenshot from 2021-10-15 13-16-22

Many thanks!