作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个带有用户和登录过程的 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/
我是一名优秀的程序员,十分优秀!