且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

验证时返回 URL

更新时间:2023-02-26 13:09:16

您可以通过指定 Accounts 来设置 URL.emailTemplates.verifyEmail.text.举个例子:

You can set the URL by specifying Accounts.emailTemplates.verifyEmail.text. Here's an example:

Accounts.emailTemplates.siteName = 'MyApp';

Accounts.emailTemplates.from = 'me@example.com';

Accounts.emailTemplates.verifyEmail.subject = function() {
  return 'Verify your email address on MyApp';
};

Accounts.emailTemplates.verifyEmail.text = function(user, url) {
  var token = url.split('/').pop();
  var verifyEmailUrl = Meteor.absoluteUrl("verify-email/" + token);
  return verifyEmailEmailBody(verifyEmailUrl);
};

回调采用 url 参数,它是meteor 生成的默认 URL.您可以提取验证令牌,然后使用它来构建自定义 URL.该函数需要返回一个正文字符串,您将通过实现 verifyEmailEmailBody 生成该字符串.

The callback takes a url parameter which is the default URL generated by meteor. You can extract the verification token and then use it to build a custom URL. The function needs to return a body string, which you'll generate by implementing verifyEmailEmailBody.

在客户端,您需要设置相应的路由.当路由运行时,您可以调用Accounts.verifyEmail.

On the client, you'll need to set up the corresponding route. When the route is run, you can call Accounts.verifyEmail.