【问题标题】:How to cutomise the url sent with Meteor Accounts.ui forgetpassword如何自定义使用 Meteor Accounts.ui 发送的 url 忘记密码
【发布时间】:2021-01-18 15:55:15
【问题描述】:

我正在使用 accounts.ui 忘记密码

Accounts.forgotPassword({email: "test@test.com"}, function (e, r) {
    if (e) {
        console.log(e.reason);
    } else {
        // success
    }
}); 

当我发送忘记密码的电子邮件时,我只是收到以下电子邮件

谁能告诉我如何简单地更改网址并使用相同的令牌发送令牌

我尝试使用下面的代码,但没有成功

ma​​in.js(客户端)

Meteor.startup(() => {
  Accounts.resetPassword.text = function(user, url) {
    url = url.replace('#/', '/');
    console.log("url ==== ", url)
    return `Click this link to reset your password: ${url}`;
  }
});

【问题讨论】:

  • “它没有用”到底是什么意思?你在ui上使用路由器吗?给定的自定义 url 是否存在带有相关模板的路由?

标签: meteor meteor-accounts


【解决方案1】:

在服务器端:

Accounts.emailTemplates.resetPassword.subject = function () {
  return "Forgot your password?";
};

Accounts.emailTemplates.resetPassword.text = function (user, url) {
  return "Click this link to reset your password:\n\n" + url;
};

阅读:https://docs.meteor.com/api/passwords.html#Accounts-emailTemplates

【讨论】:

猜你喜欢
  • 2015-06-22
  • 1970-01-01
  • 2016-09-13
  • 1970-01-01
  • 2020-09-23
  • 2016-08-31
  • 2015-12-21
  • 1970-01-01
  • 2011-02-19
相关资源
最近更新 更多