Symfony2 的新用户在这里。
我正在尝试使用 FOSUserBundle 设置防火墙。
在/admin/需要用户成为管理员之后,我已经拥有了一切。
但是,我想将登录路径移动到/admin/login而不仅仅是/login
安全.yml
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:
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
anonymous: true
access_control:
- { path: ^admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^admin/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
路由.yml
pwd_admin:
resource: "@PWDAdminBundle/Resources/config/routing.yml"
prefix: /admin
pwd_website:
resource: "@PWDWebsiteBundle/Resources/config/routing.yml"
prefix: /
fos_js_routing:
resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /admin/register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
尝试访问/admin/login时出现以下错误
No route found for "GET /admin/login
编辑:路线
fos_user_security_login ANY ANY ANY /login
fos_user_security_check POST ANY ANY /login_check
fos_user_security_logout ANY ANY ANY /logout
fos_user_profile_show GET ANY ANY /profile/
fos_user_profile_edit ANY ANY ANY /profile/edit
fos_user_registration_register ANY ANY ANY /admin/register/