我在我的Symfony项目中安装了FOS用户包。我正在遵循Symfony文档中的步骤,然后我重写了两个模板 - layout.html.twig和Security / login_content.html.twig。但是现在我发现/ register页面不起作用,它返回错误说ERR_TOO_MANY_REDIRECTS,/ login工作正常。几个星期前我在不同的项目上做了同样的事情,并且/ register页面在那里工作得很好。所以我不得不弄乱一些东西,但我无法弄清楚是什么。覆盖的模板在两个项目中都是相同的,与config.yml中的security.yml和fos部分相同。它甚至无法访问供应商FOS目录中RegistrationController.php中的registerAction(),因此路由必定存在一些问题,它无法采取适当的措施。缓存已清除。有什么想法吗?
security.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
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: /_wdt/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: /_profiler/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin, role: ROLE_ADMIN }
- { path: ^/, role: ROLE_USER }
的routing.yml
app:
resource: "@AppBundle/Controller/"
type: annotation
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
config.yml
# FOS User Bundle
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
address: admin@test.com
sender_name: admins