Form is always valid! Why?
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.
The problem is probably lying in your security.yml
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 }
Did you manage to fix your problem ? I'm facing a similar issue.
Unfortunately not :|
If you change
'constraints' => array(new RecaptchaTrue(array("groups" => "contest"))),
by
'constraints' => array( new RecaptchaTrue()),
The problem solve I think...