2014-09-23 137 views
0

在我的Meteor应用程序中,我有一个注册表格/signup,需要用户名,密码和电子邮件。提交此表格后,用户将通过Accounts.createUser()自动登录到网站,并通过Accounts.config({sendVerificationEmail: true})向用户的电子邮件地址发送电子邮件验证邮件。流星:验证电子邮件链接正在记录用户

就像我说的,用户在这一点上自动登录,但是有一个未经验证的电子邮件地址。问题在于,一旦用户点击电子邮件中的电子邮件验证链接,它们将被导向至/verify-email/:token(例如http://domain.com/#/verify-email/35_7bRc_kXyUfRnlB7LB9NFGUyEDPH8E8pTPXKeDBY6),其重定向至/,并且在该过程中某处用户变为LOGGED OUT。 Meteor.user()返回null,所以我不能验证电子邮件地址,直到他们再次手动登录(然后我才能处理令牌)。

为什么用户通过此链接注销?我注意到,只需在重定向到/后刷新页面,用户就会重新登录(无需重新输入凭据)。这是我的铁路由器文件,如果有帮助:

/* Declare global router configurations */ 
Router.configure({ 
    layoutTemplate: 'layout', 
    notFoundTemplate: 'noData', 
}); 

/* Prevent templates from rendering before data is ready */ 
Router.onBeforeAction(function(pause) { 
    if (!this.ready()) { 
    pause(); 
    } 
}); 

/* Define routes */ 
Router.map(function() { 
    this.route('home', { 
    path: '/' 
    }); 
    this.route('signup', { 
    }); 
    this.route('login', { 
    }); 
    this.route('forgot', { 
    }); 
    this.route('ohlc', { 
    progress: { 
     enabled: true 
    }, 
    controller: 'ohlcController' 
    }); 
    //this.route('kitchensink', {}); 
    this.route('404', { 
    path: '/*' 
    }); 
}); 

我是否需要额外的路径/配置来处理/verify-email/:token?谢谢!

回答

相关问题