我遇到了令我惊讶的错误,因为在security.yaml文件下面
default_target_path: createEvent
给我一个错误。 如果我在security.yaml中包含default_target_path:createEvent,我将得到
The file "E:\Symfony\myproj\config/packages/security.yaml" does not contain valid YAML in E:\Symfony\myproj\config/packages/security.yaml (which is loaded in resource "E:\Symfony\myproj\config/packages/security.yaml").
如果我删除default_target_path,那么它运行良好,但是登录后无法重定向。
security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
encoders:
App\Entity\User:
algorithm: bcrypt
providers:
db_provider:
entity:
class: App\Entity\User
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 }
答案 0 :(得分:0)
检查您的控制器中的路径名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