Hi everyone,
I haven't actually tested to see if there is indeed a bug but the discussion leads me to believe that you're forgetting a crucial step (the way I understand it)
You HAVE to be logged in to the local account for linking to work. The email is irrelevant.. LB does not link accounts based on email but based on the fact that it's the same person/token that has access to both accounts
local log in as that user
go to /link/facebook with the access token set as a logged in local user and log in with FB
that way the local and FB accounts are linked even if the fb account has a different email....it's completely irrelevant
The code above is clear as day with regards to the fact:
if (link) { //if this is a linking log in request
if (req.user) { // and this user is logged in already with some account X
self.userCredentialModel.link(
req.user.id, name, authScheme, profile,
{accessToken: accessToken, refreshToken: refreshToken}, options, done); //link the logged in user with the profile of the new login } else {
done('No user is logged in'); //no user is already logged in, so there is nothing to link with....it does NOT search by email
}