[英]How do you change the reset password URL in meteor?
I am using meteor along with the accounts-password package. 我正在使用meteor和accounts-password包。 I'm rolling my own login and password changing/resetting UI and want to know...
我正在滚动我自己的登录名和密码更改/重置UI,想知道...
How can I customize the password reset link in the reset password email sent as a result of Accounts.resetPassword
? 如何自定义由
Accounts.resetPassword
发送的重置密码电子邮件中的密码重置链接?
Currently it in the form like so: /#/reset-password/<id>'
. 目前它的形式如下:
/#/reset-password/<id>'
。 Since I am using meteor router , I would like to send in the form '/reset-password/<id>'
so I can catch it with the route '/reset-password/:id'
. 由于我使用的是流星路由器 ,我想以
'/reset-password/<id>'
的形式发送,所以我可以使用路径'/reset-password/:id'
来捕获它。
Late to the party ... 迟到了...
Instead of changing the whole text, you can just change the url with: 您无需更改整个文本,只需更改网址:
Meteor.startup(function() {
Accounts.urls.resetPassword = function(token) {
return Meteor.absoluteUrl('reset-password/' + token);
};
});
It has changed a little bit: 它改变了一点:
You have to use 你必须使用
Accounts.emailTemplates.resetPassword.text
For the url you can simply replace the hashbang instead of parsing the token from the url. 对于url,您可以简单地替换hashbang而不是从url解析令牌。 As an example (in coffeescript):
作为一个例子(在coffeescript中):
Meteor.startup(() ->
Accounts.emailTemplates.resetPassword.text = (user, url) ->
url = url.replace('#/', '')
return "Click this link to reset your password: " + url
)
ES6 ES6
Meteor.startup(() =>
Accounts.emailTemplates.resetPassword.text = function(user, url) {
url = url.replace('#/', '');
return `Click this link to reset your password: ${url}`;
}
);
See the section on email templates in the Meteor docs : 请参阅Meteor文档中有关电子邮件模板的部分 :
resetPassword: An Object with two fields:
resetPassword:具有两个字段的对象:
- resetPassword.subject: A Function that takes a user object and returns a String for the subject line of a reset password email.
resetPassword.subject:一个函数,它接受用户对象并返回重置密码电子邮件主题行的字符串。
- resetPassword.text: A Function that takes a user object and a url , and returns the body text for a reset password email.
resetPassword.text:一个获取用户对象和URL的函数,并返回重置密码电子邮件的正文。
You can customise which url is passed to the reset password email method: 您可以自定义将哪个网址传递给重置密码电子邮件方法:
Accounts.resetPassword.text = function(user, url) {
return "Click this link to reset your password: /reset-password/" + myId;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.