質問

I have managed to successfully configure this. The problem is, when I change the lines below :

//I have set all requested data with the user's username
//modify here with relevant data
$user->setUsername($username);
$user->setEmail($username);
$user->setPassword($username);

into the information I want to retrive, such as real name, email, my generated password etc, when I click the Login button for Facebook per say, I am asked again if I want to connect with my local testing site.

From what I understand, in the documentation I linked above, this :

$user = $this->userManager->findUserBy(array($this->getProperty($response) => $username));

is the line that checks if the user exists or not, and the initial code by itself, sets either facebook_id or twitter_id (this is how I save them) as a new User *username*. If I change the line

$user->setUsername($username); //same as facebook/twitter _id

into

$user->setUsername(setProperUsername()); //sets a proper unique username

Then everytime I try to login I get the "Register" message. So, I have a general idea of how it works but I am having a hard time understanding some things:

1. When I have registered with Facebook and I login with twitter, I register again, no knew row is created, but missing twitter_id fields are updated/populated, username stays intact. How come HWI/FOSUB knows I am the same person when my previous data were from Facebook not Twitter?

2. If there is a global way of knowing I am the same person, what data from the $response object should I use as a key to identify already registered users?

役に立ちましたか?

解決

After testing a lot with this, I have the answer if anyone runs into this type of situation

  1. Check your default_target path, make it so it is /profile, /account etc, don't default to login again. Also, if a user is already logged in, do not make him access your login page. This was why my data was being updated. I was basically logged in with my Facebook account and registering with my Twitter account too.

  2. No, there is no global way of knowing I am the same person. The $response object sent me a unique ID for that specific user according to the provider policy. You might use this to identify already registered users and log them in.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top