【问题标题】:Meteor: Verify Email Link is Logging User OutMeteor:验证电子邮件链接正在注销用户
【发布时间】:2014-09-23 09:09:56
【问题描述】:

在我的 Meteor 应用程序中,我有一个 /signup 的注册表单,需要用户名、密码和电子邮件。提交此表单后,用户将通过Accounts.createUser() 自动登录到该站点,并且通过Accounts.config({sendVerificationEmail: true}) 将电子邮件验证消息发送到用户的电子邮件地址。

就像我说的那样,此时用户会自动登录,但使用的是未经验证的电子邮件地址。问题是,一旦用户单击电子邮件中的电子邮件验证链接,他们就会被定向到/verify-email/:token(例如http://domain.com/#/verify-email/35_7bRc_kXyUfRnlB7LB9NFGUyEDPH8E8pTPXKeDBY6),然后重定向到/,并且在此过程中的某个地方用户会退出。 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?谢谢!

【问题讨论】:

    标签: javascript meteor iron-router


    【解决方案1】:

    这个问题线程解决了我的问题:https://github.com/EventedMind/iron-router/issues/3

    似乎是 Iron-router 的一个已知问题,但该线程有一个解决方法。

    【讨论】:

      猜你喜欢
      • 2022-11-12
      • 1970-01-01
      • 2016-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-06
      • 2021-10-21
      • 2021-01-07
      相关资源
      最近更新 更多