gpt4 book ai didi

symfony - 用于登录 Symfony 4 的多个提供商和防火墙

转载 作者:行者123 更新时间:2023-12-01 21:58:02 26 4
gpt4 key购买 nike

我有一个带有用户和登录过程的 Symfony 4 网站。我想添加一个新实体“客户”并允许客户使用与用户相同的流程登录。

当我尝试编辑 security.yaml 文件时,出现此错误:未明确配置“主”防火墙上“守卫”监听器的提供程序是不明确的,因为存在不止一个注册提供者。

我的编码器已声明:

encoders:
App\Entity\User:
algorithm: bcrypt
App\Entity\Client:
algorithm: bcrypt

我的提供者也是:供应商:

app_user_provider:
entity:
class: App\Entity\User
property: email
manager_name: user
app_customer_provider:
entity:
class: App\Entity\Customer
property: email
manager_name: customer

和主防火墙:

main:
logout:
path: app_logout
anonymous: true
guard:
authenticators:
- App\Security\LoginFormAuthenticator

我尝试了不同的方式来声明新的防火墙,但它不起作用。是否可以对两个提供商使用相同的安全流程?我错过了什么吗?

谢谢

最佳答案

你应该将提供商添加到你的防火墙,因为你有多个提供商 symfony 不知道你想使用哪一个,所以尝试像这样配置你的防火墙

 main:
logout:
path: app_logout
anonymous: true
provider: app_user_provider
guard:
authenticators:
- App\Security\LoginFormAuthenticator

不要忘记缓存:清除你可以在他们的文档中找到它 here

关于symfony - 用于登录 Symfony 4 的多个提供商和防火墙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55324629/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com