用户没有用户提供程序,symfony 3.4.37 和 4.4.3 [英] There is no user provider for user, symfony 3.4.37 and 4.4.3

查看:22
本文介绍了用户没有用户提供程序,symfony 3.4.37 和 4.4.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从升级到 Symfony 3.4.37 以来,我遇到了这个问题

Since the upgrade to Symfony 3.4.37, I'm having this issue

用户Mybundle\Myuser"没有用户提供程序.

There is no user provider for user "Mybundle\Myuser".

使用 3.4.36 及更早版本,它运行良好.

With version 3.4.36 and previous, it was working fine.

security.yml

security.yml

security:
  providers:
    myprovider:
        id: myuser.provider

services.yaml

services.yaml

myuser.provider:
    class: Mybundle\MyUserProvider
    public: true
    arguments: 
        - '@arg1'
    tags:
        - { name: monolog.logger, channel: app.oneid.provider }

知道如何解决这个问题吗?

Any idea on how to fix this issue?

我的用户提供者的支持类:

The support class of my user provider:

public function supportsClass($class)
{
    return MyUserProvider::class === $class;
}

推荐答案

UserProvider 支持方法应该测试 User 类,而不是 UserProvider.所以:

The UserProvider supports method should be testing the User class, not the UserProvider. So:

public function supportsClass($class)
{
    return MyUser::class === $class;
}

有趣的是(至少对我而言)是 3.4 和 4.4 的早期版本似乎都可以工作.较早的代码要么没有调用支持方法,要么没有检查返回值.有点奇怪,这种问题花了这么长时间才解决.

What is interesting (to me at least) is that earlier versions of both 3.4 and 4.4 appeared to work. The earlier code was either not calling the supports method or not checking the return value. Kind of strange that this sort of problem took so long to fix.

我继续发布了一个答案,因为我怀疑其他开发人员在升级时可能会遇到这个问题.

I went ahead and posted an answer because I suspect other developers might run into this as they upgrade.

这篇关于用户没有用户提供程序,symfony 3.4.37 和 4.4.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆