Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serviceAddedCallback not firing when user tries to login with a new service #35

Open
davidsyoung opened this issue Dec 12, 2015 · 1 comment

Comments

@davidsyoung
Copy link

Hey,

Not sure if this is intended or not, but serviceAddedCallback does not fire when a user that is not logged in tries to login with a service that another user has a verified email matching (this happens at line 593 of accounts-meld-server.js).

The reason I had to get this to fire is because I have an onCreateUser callback that fires when someone logs in with Facebook for the first time that copies info into the user.profile object.

In order to make this happen I called the original function storing the return value (to be returned after), called the callback and returned the return value. Reason for calling the original function is so that it copies the new service data into the user.

All works. I'm not great with git/github so here is the code I used starting from line 633 of accounts-meld-server.js:


// Now calls original updateOrCreateUserFromExternalService
var returnValue = origUpdateOrCreateUserFromExternalService.apply(this, arguments);

// Updates the registered_emails field
AccountsEmailsField.updateEmails({
    user: otherUser
});

// Need to also call serviceAddedCallback when a service is added to a non-logged in user
var serviceAddedCbk = AccountsMeld.getConfig('serviceAddedCallback');
if (serviceAddedCbk) {
    serviceAddedCbk(otherUser._id, serviceName);
}

// Return the previous return value here to avoid calling
// original function again
return returnValue;

Hope this helps. Dave

@ergousha
Copy link

Yes, I also experience serviceAddedCallback not firing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants