EWZRecaptchaBundle icon indicating copy to clipboard operation
EWZRecaptchaBundle copied to clipboard

Form is always valid! Why?

Open szonyim opened this issue 7 years ago • 5 comments

I'm tried to implement by documentation, but my form is always valid.

  • Symfony version: 2.8
  • Recaptcha bundle version: ^1.5

Here is my code: config.yml

ewz_recaptcha:
    public_key:  "blablabla"
    private_key: "blablabla2"
    locale_key:  %kernel.default_locale%
    locale_from_request: true
    enabled: true
    ajax: false

form add code

...->add('recaptcha', EWZRecaptchaType::class, [
                'label' => 'Nem vagyok robot',
                'attr' => [
                    'options' => [
                        'theme' => 'light',
                        'type'  => 'image',
                        'size'  => 'normal',
                        'defer' => true,
                        'async' => false
                    ]
                ],
                'mapped'      => false,
                'constraints' => array(
                    new RecaptchaTrue(array("groups" => "contest"))
                ),
                'error_bubbling' => true,
                'required' => true
            ])

If change constraints to new RecaptchaTrue(array("groups" => "Default")), I got an error message:

The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL.

Can you help me?

Thanks, d.

szonyim avatar Apr 07 '18 15:04 szonyim

The problem is probably lying in your security.yml

someniatko avatar Apr 11 '18 14:04 someniatko

Here is my security.yml. What I have to do? Please help.

security:
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    role_hierarchy:
            ROLE_ADMIN:       ROLE_USER
            ROLE_SUPER_ADMIN: ROLE_ADMIN

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js|vendor|media)/
            security: false

        admin:
            pattern: ^/admin
            form_login:
                provider: fos_userbundle
                csrf_provider: form.csrf_provider
                login_path: fos_user_security_login
                check_path: fos_user_security_check
            remember_me:
                secret: "%secret%"
                lifetime: 604800 # 7 nap
                domain: ~
                path: /admin
            logout:
                path:   fos_user_security_logout
                target: fos_user_security_login

            logout:       true
            anonymous:    true

    access_control:
        - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, role: ROLE_ADMIN }

szonyim avatar Apr 12 '18 19:04 szonyim

Did you manage to fix your problem ? I'm facing a similar issue.

Th3BiSh0p avatar Jun 18 '18 12:06 Th3BiSh0p

Unfortunately not :|

szonyim avatar Jul 09 '18 18:07 szonyim

If you change

'constraints' => array(new RecaptchaTrue(array("groups" => "contest"))),

by

'constraints' => array( new RecaptchaTrue()),

The problem solve I think...

Chrysweel avatar Mar 29 '21 12:03 Chrysweel