FOSUser check_path with localization

How to set login path from user locale? I tried

check_path: / {_ locale} / login_check

and

check_path: /(en|ru)/login_check 

but nothing ((

Route configuration

 fos_user_security: resource: "@FOSUserBundle/Resources/config/routing/security.xml" prefix: /{_locale} 

An exception:

You must configure the verification path to be processed by the firewall using form_login in the security firewall configuration.

+4
source share
2 answers

Hm, I did not recognize your prefix: /{_locale} in

 resource: "@FOSUserBundle/Resources/config/routing/security.xml" 

You must write the route to your action in (for exmpl ofc) routing.yml :

 login_check: pattern: /{_locale}/login_check defaults: { _controller: YourBundle:Controller:someaction, _locale: en } requirements: _locale: en|ru 

and security.xml :

 check_path: /{_locale}/login_check 

Do not forget to add

 fos_user_security: resource: "@FOSUserBundle/Resources/config/routing/security.xml" 

in your app/config/routing.yml .

try it, gl.

+1
source

Use routes instead of paths in your firewall configuration:

  security: firewalls: main: form_login: provider: fos_userbundle login_path: fos_user_security_login check_path: fos_user_security_check csrf_provider: form.csrf_provider 

symfony forum topic link

+12
source

Source: https://habr.com/ru/post/1388011/


All Articles