将服务连接到现有的流星帐户 [英] Connect service to existing meteor account

查看:33
本文介绍了将服务连接到现有的流星帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置一个流星应用程序,需要使用用户名和密码进行注册,然后希望将该帐户与 facebook 和 twitter 相关联.

I am setting up a meteor app that involves signing up with a username and password, then hopefully connecting that account with facebook and twitter.

我已经轻松启动并运行了第一部分,只需使用帐户包.但是当我有一个登录的用户调用 Meteor.loginWithFacebook() 时,它会将它们注销并创建一个新帐户.我想要的是将 facebook 凭据添加到当前登录用户的东西.

I have the first part up and running easily, just with the accounts package. But when I have a logged in user call Meteor.loginWithFacebook(), it logs them out and creates a new account. What I want is something that adds the facebook credentials to the currently logged in user.

流星文档有这个:

{
  _id: "bbca5d6a-2156-41c4-89da-0329e8c99a4f",  // Meteor.userId()
  username: "cool_kid_13", // unique name
  emails: [
    // each email address can only belong to one user.
    { address: "cool@example.com", verified: true },
    { address: "another@different.com", verified: false }
  ],
  createdAt: Wed Aug 21 2013 15:16:52 GMT-0700 (PDT),
  profile: {
    // The profile is writable by the user by default.
    name: "Joe Schmoe"
  },
  services: {
    facebook: {
      id: "709050", // facebook id
      accessToken: "AAACCgdX7G2...AbV9AZDZD"
    },
    resume: {
      loginTokens: [
        { token: "97e8c205-c7e4-47c9-9bea-8e2ccc0694cd",
          when: 1349761684048 }
      ]
    }
  }
}

这似乎是一个用户名也通过 Facebook 身份验证的帐户.但我不确定这是否只是一个示例,您实际上无法使用基本的 Meteor 内容来实现.

which appears to be an account with a username that's also authenticated with Facebook. But I'm not sure if that's just an example that you can't actually achieve with basic Meteor stuff.

我想做的基本上是

Meteor.connectWithExternalAccount();

它运行与 Meteor.loginWithExternalAccount() 相同的进程,但只是将信息添加到当前登录的用户中.

which runs the same process as Meteor.loginWithExternalAccount(), but just adds the information to the currently logged in user.

如果有人能稍微解释一下 account-base 包,这样我就可以知道自己从哪里开始,那就太好了.

If someone could just explain the accounts-base package a bit so I could know where to start for myself that would be great.

另外,有谁知道这是否会包含在 Meteor 的任何未来版本中?

Also, does anyone know if this will be included in any future versions of Meteor?

推荐答案

所以一直在努力解决这个问题,但不幸的是 pull request https://github.com/meteor/meteor/pull/1133 从未合并.可能你最好的办法是检查流星核心谷歌群组,看看是否有任何评论,如果没有,看看你是否可以让核心开发人员对其发表评论.

So there's been work to solve this problem, but unfortunately the pull request https://github.com/meteor/meteor/pull/1133 never got merged. Probably your best bet is check the meteor-core Google Groups and see if there was any comment on it and if not, see if you can get a core dev to comment on it.

如果你仍然想使用 pull request,你可以做的是删除各种 Meteor accounts-* 包,然后在你的项目的根目录中,创建一个 /packages 文件夹并将 yubozhao 打补丁的 accounts-* 包复制到那里(可能很聪明地附加 -custom).然后,您可以meteor add accounts-base-custom 等将它们添加到您的项目中.

If you want to still use the pull request, what you could do is remove the various Meteor accounts-* packages, then in the root of your project, create a /packages folder and copy yubozhao's patched accounts-* packages in there (probably smart to append -custom). You'd then meteor add accounts-base-custom, etc. to add them to your project.

但是请注意,yubozhao 是在 6-7 个月前写的,您可能需要坚持使用当时最新的任何版本的 Meteor 才能使其正常工作.

Note though, yubozhao wrote this is 6-7 months ago and you may need to stick with whatever version of Meteor that was current then for it to work.

2014 年 4 月更新:现在有一个 Atmosphere 包,它有一个可能有用的类似用例:https://atmospherejs.com/package/accounts-merge

Update April 2014: There's an Atmosphere package now that has a similar use case that might be useful: https://atmospherejs.com/package/accounts-merge

这篇关于将服务连接到现有的流星帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆