Closed bellecp closed 12 years ago
I ran also into this bug and this patch fixed it.
this sounds fishy to me. not sure if something has changed some where else, but i don't see why we would need to set the Facebook id based on the username inside refresh user. this defiantly looks like the wrong fix, but i am not sure why it would even be needed to begin with.
I think I know what the issue is: the facebook id may not be part of the serialized data so it is not available when unserializing the data. the good fix in this case would be to extend the serialization defined by FOSUserBundle:
<?php
use FOS\UserBundle\Entity\User as BaseUser
class User extends BaseUser
{
// ...
public function serialize()
{
return serialize(array($this->facebookId, parent::serialize()));
}
public function unserialize($data)
{
list($this->facebookId, $parentData) = unserialize($data);
parent::unserialize($parentData);
}
}
then again if the user name is the Facebook id, then maybe the if statement in refreshUser() should just be adapted.
yeah, if it is the username, the statement need to be adapted, or the getFacebookId method to return the username
that code is taken from the LiipHelloBundle .. would be nice if someone could look into our comments to see if you can come up with a proper fix .. otherwise i will check if i can get it to work inside the LiipHelloBundle ..
After following all the instructions from FOSUserBundle and FOSFacebookBundle to set up an external facebook auth that triggers symfony security mechanism, I ended up with the error :
when accessing /login_check (redirected from facebook.com) The exception was thrown in the refreshUser method.
It seemed that at this point, $user had a username but no facebookId. Adding the proposed line solves the issue. (but is it the good way to solve it ?...)