You must configure the check path to be handled by the firewall using form_login in your security firewall configuration

前端 未结 4 866
囚心锁ツ
囚心锁ツ 2021-01-04 11:46

i have webservice which is provider for my \"regular\" users. I want to use FosUserBundle for my administrators. Above is my security configuration. regular users login work

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-04 12:11

    Your code is wrong only in the part of check_path value.

    This is your original code:

    firewalls:               
        main:
            pattern: ^/admin
            form_login:
                provider:               fos_userbundle
                login_path:             fos_user_security_login 
                check_path:             fos_user_security_check
                csrf_provider:          form.csrf_provider
                logout:       true
                anonymous:    true
    

    And you should use something like:

    firewalls:               
        main:
            pattern: ^/admin
            form_login:
                provider:               fos_userbundle
                login_path:             fos_user_security_login 
                check_path:             /login_check
                csrf_provider:          form.csrf_provider
                logout:       true
                anonymous:    true
    

    Note that check_path has as value only a string. If you use the value fos_user_security_check you are calling to SecurityController.php class and invoking the checkAction() method which exactly only throws an RuntimeError Exception with the error displayed "You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.". So the fix is so simple that not use the value fos_user_security_check

提交回复
热议问题