Javascript Meteor:验证电子邮件链接是否正在注销用户
在我的Meteor应用程序中,我在Javascript Meteor:验证电子邮件链接是否正在注销用户,javascript,meteor,iron-router,Javascript,Meteor,Iron Router,在我的Meteor应用程序中,我在/signup上有一个注册表单,需要用户名、密码和电子邮件。提交此表单后,用户将通过Accounts.createUser()自动登录到站点,并通过Accounts.config({sendVerificationEmail:true})向用户的电子邮件地址发送电子邮件验证消息 正如我所说,用户此时会自动登录,但使用的电子邮件地址未经验证。问题在于,一旦用户单击电子邮件中的电子邮件验证链接,他们就会被定向到/verify email/:token(例如),从而重
/signup
上有一个注册表单,需要用户名、密码和电子邮件。提交此表单后,用户将通过Accounts.createUser()
自动登录到站点,并通过Accounts.config({sendVerificationEmail:true})
向用户的电子邮件地址发送电子邮件验证消息
正如我所说,用户此时会自动登录,但使用的电子邮件地址未经验证。问题在于,一旦用户单击电子邮件中的电子邮件验证链接,他们就会被定向到/verify email/:token
(例如),从而重定向到/
,在此过程中,用户会在某处注销Meteor.user()
返回null
,因此我无法验证电子邮件地址,直到他们再次手动登录(然后我可以处理令牌)
为什么用户通过此链接注销?我注意到,只要在重定向到/
后刷新页面,用户就可以重新登录(无需重新输入凭据)。以下是我的iron router文件(如果有帮助):
/* 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
?谢谢 此问题线程解决了我的问题:
这似乎是铁路由器的一个已知问题,但该线程有一个解决方法