fosuserbundle不是loggin int PRO模式

时间:2016-03-25 12:05:08

标签: symfony fosuserbundle

我在生产中记录用户时遇到问题

我的secutiry.yml文件如下:

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

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN

providers:
    fos_userbundle:
        id: fos_user.user_provider.username_email

firewalls:
main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_token_generator: security.csrf.token_manager
            # if you are using Symfony < 2.8, use the following config instead:                                                                                                                                                            
            # csrf_provider: form.csrf_provider                                                                                                                                                                                            

        logout:       true
        anonymous:    true

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

和我的config.yml的一部分:

  # Doctrine Configuration                                                                                                                                                                                                                       
 doctrine:
dbal:
    driver:   pdo_mysql
host:     mysql-paradasym85.alwaysdata.net
port:     3306
dbname:   paradasym85_symfony
user:     user
password: pass123456 (fake)
charset:  UTF8
# if using pdo_sqlite as your database driver:                                                                                                                                                                                         
#   1. add the path in parameters.yml                                                                                                                                                                                                  
#     e.g. database_path: "%kernel.root_dir%/data/data.db3"                                                                                                                                                                            
#   2. Uncomment database_path in parameters.yml.dist                                                                                                                                                                                  
    #   3. Uncomment next line:                                                                                                                                                                                                            
    #     path:     "%database_path%"                                                                                                                                                                                                      

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    naming_strategy: doctrine.orm.naming_strategy.underscore
    auto_mapping: true

一切在开发中都能正常工作,但在生产模式下却无法正常工作

似乎/ login_check无效。

问候。

1 个答案:

答案 0 :(得分:0)

我猜您在routing_dev.yml而不是routing.yml中导入了FOSUserBundle的路由。

# app/config/routing.yml
fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

在路由更改后清除生产缓存!

app/console cache:clear --env="prod"

您可以检查路线是否在prod环境中正确注册:

app/console router:debug --env="prod"

否则,您无法正确生成表单操作的URL。 这应该在你的模板中:

<form action="{{ path("fos_user_security_check") }}">