yii2-usuario
yii2-usuario copied to clipboard
Argument 1 passed to Da\User\Event\SocialNetworkAuthEvent::__construct() must be an instance of Da\User\Model\SocialNetworkAccount, bool given
When I use for FIRST time it works perfectly, and save record in the database.
But when I try to use it as second time (with an already registered user), I always have this error when coming back from the social network:
Argument 1 passed to Da\User\Event\SocialNetworkAuthEvent::__construct() must be an instance of Da\User\Model\SocialNetworkAccount, bool given
The URL at top is like this (in case of Google, but it happens with all social networks) https://mydomain.com/user/security/authclient/google?state=XXXXXXXXXXXXXXXXXXXXXXXX&code=XXXXXXXXXXXXXXXXXXXXXXXX&scope=email+profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&authuser=7&prompt=none#
Why is this?
It starts with the "SocialNetworkAuthEvent" object, but in some point , it's "lost" with a "false":
(this screenshot is with LinkedIn ... as I said, it happens with all social networks)
Guys, this is insane ... after debugging a lot I fixed it with this:
adding
return $account;
in line 95 of https://github.com/2amigos/yii2-usuario/blob/master/src/User/Service/SocialNetworkAccountConnectService.php
if not, that function returns "false" (when the account already exists in the social_account table), and that "false" is tried to be injected in the Da\User\Event\SocialNetworkAuthEvent class, therefore, the above error appears.
Can't believe this is happen just to me.
I never used social auth, but indeed your fix looks correct...
Same happened here, worked with this fix in PHP 7.4.12.
Guys, this is insane ... after debugging a lot I fixed it with this:
adding
return $account;in line 95 of https://github.com/2amigos/yii2-usuario/blob/master/src/User/Service/SocialNetworkAccountConnectService.php
if not, that function returns "false" (when the account already exists in the social_account table), and that "false" is tried to be injected in the Da\User\Event\SocialNetworkAuthEvent class, therefore, the above error appears.
Can't believe this is happen just to me.