我收到了一个错误,这让我感到惊讶,因为在下面的security.yaml文件中
default_target_path: createEvent
给了我一个错误。如果我在security.yaml中包含default_target_path:createEvent,我会得到
The file "E:Symfonymyprojconfig/packages/security.yaml" does not contain valid YAML in E:Symfonymyprojconfig/packages/security.yaml (which is loaded in resource "E:Symfonymyprojconfig/packages/security.yaml").
如果我删除default_target_path,那么它运行良好,但登录后无法重定向。
security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
encoders:
AppEntityUser:
algorithm: bcrypt
providers:
db_provider:
entity:
class: AppEntityUser
property: uname
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: true
provider: db_provider
form_login:
login_path: login
check_path: login
default_target_path: createEvent
logout:
path: /logout
target: /login
access_control:
- { path: ^/login/, roles: ROLE_ADMIN }
- { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
# - { path: ^/profile, roles: ROLE_USER }
检查控制器中的路径名createEvent
是否正确,并将其添加到security.yml
文件中
form_login:
login_path: login
check_path: login_check
always_use_default_target_path: false
default_target_path: YOUR_PATH_NAME
logout:
path: logout
target: login