Symfony 4.4 FOS user-bundle api/auth/login 在 null 上调用成员函数 findOneBy()
Posted
技术标签:
【中文标题】Symfony 4.4 FOS user-bundle api/auth/login 在 null 上调用成员函数 findOneBy()【英文标题】:Symfony 4.4 FOS user-bundle api/auth/login Call to a member function findOneBy() on null 【发布时间】:2020-10-27 01:50:55 【问题描述】:我通过 docker 使用 symfony 4.4 并在前一段时间安装了 FOS 用户包。一切正常,但最近在尝试登录时,我不断收到错误
Call to a member function findOneBy() on null
。
完整的痕迹是这样的
"meta":
"code": 0,
"message": "Call to a member function findOneBy() on null",
"file": "/var/www/symfony/vendor/friendsofsymfony/user-bundle/Doctrine/UserManager.php",
"line": 76,
"trace": [
"file": "/var/www/symfony/vendor/friendsofsymfony/user-bundle/Model/UserManager.php",
"line": 58,
"function": "findUserBy"
,
"file": "/var/www/symfony/vendor/friendsofsymfony/user-bundle/Security/UserProvider.php",
"line": 93,
"function": "findUserByUsername"
,
"file": "/var/www/symfony/vendor/friendsofsymfony/user-bundle/Security/UserProvider.php",
"line": 43,
"function": "findUser"
,
"file": "/var/www/symfony/vendor/symfony/security-core/User/ChainUserProvider.php",
"line": 56,
"function": "loadUserByUsername"
,
"file": "/var/www/symfony/vendor/symfony/security-core/Authentication/Provider/DaoAuthenticationProvider.php",
"line": 85,
"function": "loadUserByUsername"
,
"file": "/var/www/symfony/vendor/symfony/security-core/Authentication/Provider/UserAuthenticationProvider.php",
"line": 65,
"function": "retrieveUser"
,
"file": "/var/www/symfony/vendor/symfony/security-core/Authentication/AuthenticationProviderManager.php",
"line": 85,
"function": "authenticate"
,
"file": "/var/www/symfony/vendor/symfony/security-http/Firewall/UsernamePasswordJsonAuthenticationListener.php",
"line": 137,
"function": "authenticate"
,
"file": "/var/www/symfony/vendor/symfony/security-bundle/Debug/WrappedLazyListener.php",
"line": 49,
"function": "authenticate"
,
"file": "/var/www/symfony/vendor/symfony/security-http/Firewall/AbstractListener.php",
"line": 27,
"function": "authenticate"
,
"file": "/var/www/symfony/vendor/symfony/security-bundle/Debug/TraceableFirewallListener.php",
"line": 62,
"function": "__invoke"
,
"file": "/var/www/symfony/vendor/symfony/security-http/Firewall.php",
"line": 98,
"function": "callListeners"
,
"file": "/var/www/symfony/vendor/symfony/event-dispatcher/Debug/WrappedListener.php",
"line": 126,
"function": "onKernelRequest"
,
"file": "/var/www/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php",
"line": 264,
"function": "__invoke"
,
"file": "/var/www/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php",
"line": 239,
"function": "doDispatch"
,
"file": "/var/www/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php",
"line": 73,
"function": "callListeners"
,
"file": "/var/www/symfony/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php",
"line": 168,
"function": "dispatch"
,
"file": "/var/www/symfony/vendor/symfony/http-kernel/HttpKernel.php",
"line": 134,
"function": "dispatch"
,
"file": "/var/www/symfony/vendor/symfony/http-kernel/HttpKernel.php",
"line": 80,
"function": "handleRaw"
,
"file": "/var/www/symfony/vendor/symfony/http-kernel/Kernel.php",
"line": 201,
"function": "handle"
,
"file": "/var/www/symfony/public/index.php",
"line": 25,
"function": "handle"
]
,
"links":
"self": "/api/auth/login"
,
"errors": [
"status": "500",
"code": "INTERNAL_SERVER_ERROR",
"title": "Internal Server Error"
]
注册端点在 url api/auth/register
上工作得很好,并注册了新用户。
有什么想法吗?
【问题讨论】:
欢迎来到 ***。您是否启动了任何命令来更新您的供应商库?您是否确认配方已升级? 【参考方案1】:最后我可以通过永久删除vendor
文件夹并使用composer install
重新安装所有软件包来解决问题。
作曲家更新根本没有帮助。
我仍然不确定是什么问题,但解决这个问题的方法就是这样。
【讨论】:
以上是关于Symfony 4.4 FOS user-bundle api/auth/login 在 null 上调用成员函数 findOneBy()的主要内容,如果未能解决你的问题,请参考以下文章
Symfony 2 FOS 用户捆绑引导模式 AJAX 登录
Symfony2 - 安装了 FOS 用户包的自定义身份验证提供程序
Symfony 4/JMS/FOSUser:无法从 FOS\UserBundle 序列化数据