如何在流星应用程序中重置密码 [英] How to reset password in meteor application

查看:112
本文介绍了如何在流星应用程序中重置密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建Meteor应用程序,并且正在使用oaf:accounts-entry软件包来处理我的用户注册&验证.我现在正在使用重设密码功能.但是,当我单击电子邮件重设密码链接"时,该应用程序不会向我发送任何电子邮件.有人可以帮助我或为我提供有关如何为oaf:accounts-entry程序包配置重置密码功能的说明吗?谷歌搜索后,我找不到关于如何配置它的说明.我已安装的相关软件包是:

I am building a Meteor application and am using the oaf:accounts-entry package to handle my user registration & authentication. I am working on the reset password function right now. However, when I click on "email reset password link", the application doesn't email me anything. Can someone help me or point me to instructions on how to configure the reset password function for the oaf:accounts-entry package? After doing a google search, I could not find instructions on how to configure it. The relevant packages I have installed are:

  • oaf:accounts-entry
  • accounts-password
  • email
  • oaf:accounts-entry
  • accounts-password
  • email

谢谢!

推荐答案

注意:使用Meteor JS 1.6.1.1,所需的软件包为 accounts-ui,accounts-password

NOTE: Using Meteor JS 1.6.1.1, package required are accounts-ui, accounts-password

要在注册/登录小部件中显示忘记密码链接,您需要在位置ROOT_FOLDER/client/main.js的文件中添加少量配置.代码如下,

To make forgot password link visible in the signup/sign in a widget, you need to do add little configuration in a file at location ROOT_FOLDER/client/main.js. The code is as below,

Accounts.ui.config({
    passwordSignupFields: "USERNAME_AND_EMAIL"
});

如果您不选择passwordSignupFields: "USERNAME_AND_EMAIL"并选择类似passwordSignupFields: "USERNAME_ONLY"的名称,则将无法在注册小部件中看到忘记密码选项. (没有人会告诉你这一点,我自己发现了这个奇怪的情况.不过,我不知道为什么MDG团队会这样做?)

If you do not choose passwordSignupFields: "USERNAME_AND_EMAIL" and choose something like passwordSignupFields: "USERNAME_ONLY", you won't be able to see forgot password option in the signup widget. (No one will tell you this, I discovered this weird scenario myself. Still, I wonder why MDG team did this? )

在服务器端,您还需要在Meteor.startup(()=>{});外部的位置PROJECT/server/main.js处添加一些代码,以提供用于重置密码链接的电子邮件模板.下面是您需要自行调整某些属性的代码.

At Server end you also need to add little code at location PROJECT/server/main.js just outside Meteor.startup(()=>{}); to provide an email template for reset password link. Below is the code you need to adjust some properties yourself.

var username = 'you_id@gmail.com'; 
var password = 'your password';
var server = 'smtp.gmail.com';
var port = '465';

process.env.MAIL_URL = 'smtps://' +
encodeURIComponent(username) + ':' +
encodeURIComponent(password) + '@' +
encodeURIComponent(server) + ':' + port;

process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;

Accounts.emailTemplates.from = 'support_team@yourappname.com';


Accounts.emailTemplates.siteName = 'APP NAME';

Accounts.emailTemplates.resetPassword = {
  subject(user) {
    return "Reset Password Link.";
  },
  text(user, url) {
    return `Hello! 

    Click the link below to reset your password.

    ${url}

    If you didn't request this email, please ignore it.

Thanks,
APP Team.
`
  },
  html(user, url) {
    // This is where HTML email content would go.
    // See the section about html emails below.
  }
};

步骤1:

按如下所示查看您是否能够在注册小部件上查看忘记的密码.

See if you are able to view forgot password on the signup widget as below.

步骤2:

当您单击"忘记密码"时,您应该能够在与下面相同的窗口小部件位置查看以下弹出窗口.

When you click "forgot password", you should be able to view below popup at same widget location as below.

在有效的电子邮件输入中,您必须看到成功的完整通知,最重要的是,您必须收到如下所示的用于重置密码的邮件.

on valid Email entry, you must see a success full notification and most importantly you must receive a mail for reset password link as below.

第3步:

单击链接时,您会看到一个新窗口,弹出窗口如下所示(注意:,您必须在给定令牌到期时间之前单击链接).

When you click on the link, you can see a new window with a popup as below (NOTE: You must click the link before given token expiry time).

Voila !!!只需添加一个新密码,您就会自动登录到给定页面.如上文流星所讨论的,一切都已提供给我们.您只需要配置内容并使其运行即可.

Voila!!! just add a new password and you automatically login to given page. Everything is already provided to us as discussed above by Meteor. You just need to configure the stuff and get it running.

这篇关于如何在流星应用程序中重置密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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