meteor-link-accounts icon indicating copy to clipboard operation
meteor-link-accounts copied to clipboard

Redirect style will create new user

Open zhaoyao91 opened this issue 9 years ago • 6 comments
trafficstars

it's fine to link account in popup style, but wechat-mp require to use redirect style, which is a limit of the wechat. could you please support link account with redirect style?

zhaoyao91 avatar Nov 13 '16 19:11 zhaoyao91

I'll have to look into how wechat works and from that figure out where the issue is. I don't use wechat so I won't get to this any time soon, so if someone else wants to look into this, it will be much appreciated.

StorytellerCZ avatar Dec 03 '18 20:12 StorytellerCZ

I've looked through the code and I don't see where the issue can originate. Did you make any progress on this @zhaoyao91 ? Did you try the newest version?

StorytellerCZ avatar Oct 15 '19 11:10 StorytellerCZ

This is not related to wechat. I use google and facebook, and when the flow is set to redirect a new user is created instead of adding the information to the logged in user.

I think it's because Meteor has some logic in accounts-oauth that automatically calls the default oauth login on the server if oauth information is found at page load, and that login handler automatically creates a new user, skipping the call to the callback of this package.

MastroLindus avatar Feb 19 '20 11:02 MastroLindus

The code that I am talking about is in accounts-oauth:

Meteor.startup(() => {
  const oauth = OAuth.getDataAfterRedirect();
  if (! oauth)
    return;

  // We'll only have the credentialSecret if the login completed
  // successfully.  However we still call the login method anyway to
  // retrieve the error if the login was unsuccessful.

  const methodName = 'login';
  const { credentialToken, credentialSecret } = oauth;
  const methodArguments = [{ oauth: { credentialToken, credentialSecret } }];

  Accounts.callLoginMethod({
    methodArguments,
    userCallback: err => {
      // The redirect login flow is complete.  Construct an
      // `attemptInfo` object with the login result, and report back
      // to the code which initiated the login attempt
      // (e.g. accounts-ui, when that package is being used).
      err = convertError(err);
      Accounts._pageLoadLogin({
        type: oauth.loginService,
        allowed: !err,
        error: err,
        methodName,
        methodArguments,
      });
    }
  });
});

This will call the normal oauth login handler instead of the link

MastroLindus avatar Feb 19 '20 11:02 MastroLindus

@MastroLindus Thanks a lot for locating the code. I will see what we can do to fix this in core.

StorytellerCZ avatar Jan 26 '21 16:01 StorytellerCZ

Same issue here with Google (linkWithGoogle) and loginStyle: "redirect" calls Some progress on this issue ?

micktaiwan avatar Feb 15 '22 15:02 micktaiwan