流星:resetPassword电子邮件链接行为 [英] Meteor: resetPassword email link behavior

查看:122
本文介绍了流星:resetPassword电子邮件链接行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Meteor应用程序中实现重置密码"功能.根据本教程,我有一个非常简单的实现:朱利安关于gentlenode的教程

I'm trying to implement the "reset password" functionality in my Meteor app. I have a very simple implementation of it based on this tutorial: Julien's tutorial on gentlenode

周围有几个使用相同基本方法的示例.我几乎完全像朱利安(Julien's)一样进行挖掘,但是我只使用了一个模板.如果我的会话变量sResetPassword不是false,我在模板中使用{{#if}}来显示重置密码"形式. (我不知道应该如何在Julien的示例中显示正确的模板,并且在编写时它对我不起作用-模板不会更改.)

There are several examples floating around that use this same basic approach. I did mine almost exactly like Julien's but I used only one template; I use an {{#if}} in my template that displays the 'reset password' form, if my session variable sResetPassword is not falsey. (I don't know how the correct template is supposed to get displayed in Julien's example and it doesn't work for me as it is written -- the template doesn't change.)

这是关键的代码段.两种方法都可以在我的本地应用程序上使用,但是两种方法都不能在托管(模块化)应用程序上使用.

Here's the critical piece of code. Two different methods that both work on my local app, but neither one works on my hosted (modulus) app.

/* method one
if (Accounts._resetPasswordToken) {
  Session.set('sResetPassword', Accounts._resetPasswordToken);
}

/* method two
Accounts.onResetPasswordLink( function(token) { 
    Session.set('sResetPassword', token);  
});

在我的部署版本(Modulus)上,该链接打开我的应用程序,并且直接进入开始屏幕.当我检查sResetPassword会话变量的值时,它是未定义的,因此以某种方式,令牌的值永远不会放入变量中.

On my deployed version (Modulus), the link opens up my app and just goes straight to the start screen. When I check the value of my sResetPassword session var, it's undefined, so somehow the value of the token never gets put into the var.

我们正在讨论这个话题,当您为重置密码表单使用单独的模板时,有人知道您应该如何加载正确的模板吗?

While we're on the subject, does anyone know how you are supposed to get the correct template to load when you use a separate template for the reset password form?

推荐答案

好,无论出于何种原因,用流路由器代替iron-router都可以为我解决此问题.我创建了一个仅具有登录名和重置密码功能的新应用程序,并且运行良好.我添加了iron-router,并且再次起作用,但是仅开发模式.当我在生产模式下运行它时,问题又回来了.用流路由器替换了铁路由器(在测试应用程序和我的完整应用程序中),现在问题解决了.电子邮件链接在两种模式下均可正常工作.

OK, for whatever reason, replacing iron-router with flow-router fixed this issue for me. I created a new app with only the login and reset password functionality and it worked fine. I added iron-router and again it worked, but only dev mode. When I ran it in production mode, the problem returned. Replaced iron-router with flow-router (in both the test app and my full app) and now the problem is gone. The email link works as expected in both modes.

这篇关于流星:resetPassword电子邮件链接行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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