简体   繁体   English

访问通过社交注册创建的用户文档

[英]Access user doc created with social sign up

I have two separate ways for a user to sign up to the site. 我有两种不同的方式让用户注册该网站。 One way is just simple signup and the other is a referral signup where the route has a token in it that relates to the userId of the person who referred them something like this: 一种方法是简单注册,另一种是引用注册,其中路由中包含一个令牌,该令牌与引用它们的人的userId相关,如下所示:

Router.route('referral-signup', { path: '/referral-signup/:userId'});

In this referral route, I use a Meteor method call to create a doc in the referral table structured like: {refereeId: String, referrerId: String, verified: false} that holds all the relevant info on the referee and referrer as well as if the referee's email has been verified. 在此引荐路由中,我使用Meteor方法调用在引荐表中创建一个文档,其结构如下: {refereeId: String, referrerId: String, verified: false}包含有关裁判和引荐来源的所有相关信息,以及裁判的电子邮件已通过验证。

Both of the signup flows allow for the user to use Twitter or Facebook (regular signup & referral signup). 两种注册流程都允许用户使用Twitter或Facebook(常规注册和引荐注册)。 The problem is that the Meteor method for a user Signing up with these social platforms looks like this: 问题在于,使用这些社交平台注册的用户的Meteor方法如下所示:

Meteor.loginWithTwitter({}, function(error) {
    if (error) {
        throw new Meteor.Error("Twitter login failed.");
    } else {
        Router.go('home');
        return;
    }
});  

In this function callback, I can't seem to be able to access the user that was created and thus can not make the meteor method call to create the referral doc, which is a problem if a user is referred and then signs up through a social platform. 在此函数回调中,我似乎无法访问已创建的用户,因此无法进行流星方法调用来创建引用文档,如果引用了用户然后通过社交平台。 Does anyone have any ideas on how to access the user within a social signup callback? 是否有人对在社交注册回调中如何访问用户有任何想法?

The approach I've taken in a similar situation is to put the referral token into a session variable when the referral route is called (in the route code itself). 在类似情况下,我采取的方法是在引用路由被调用时(在路由代码本身中)将引用令牌放入会话变量中。 When the user is created I use the session variable to set the referrer info and then clear it. 创建用户后,我使用会话变量设置引荐来源网址信息,然后将其清除。 This also helps in cases where the new visitor pokes around the site for awhile before actually signing up. 如果新访客在实际注册之前在网站上闲逛了一会儿,这也有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 想要在 firebase 中的文档中创建一个子集合,当用户注册到应用程序时反应原生它的子集合创建 - want to create a subcollection in document in firebase when user sign up to app in react native its children subcollection created JS AWS Cognito 注册并链接社交提供商 - JS AWS Cognito Sign up and link social provider 如何注册用户然后让他们登录并访问当前用户Parse Server? - How to sign up user and then keep them signed in and access current user Parse Server? 用户使用Parse注册时出错 - Error with User Sign up with Parse 用户注册注册错误 - User Register Sign up Error 在网站上注册解析用户 - Sign up parse user on website 您如何强制用户在打开谷歌文档时登录? - How do you force a user to sign in on opening a google doc? 我应该将cognito用户池与其他社交idps联合,还是通过userpool本身进行社交登录 - Should I federate cognito user pools along with other social idps, or have social sign in via the userpool itself 为用户注册添加密码 - Adding a secret code to user sign up 用于用户注册(注册)的 Wordpress REST API - Wordpress REST API for user sign up (registration)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM