验证时返回 URL [英] Return URL on verification

查看:29
本文介绍了验证时返回 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么设置了验证电子邮件的返回 URL.不是生成并插入电子邮件中的链接,而是当您单击该链接时,它会在经过验证后转到您网站上的页面.如何设置它转到哪个页面?

What sets the return URL for the verification email. Not the link that gets generated and inserted in the email, but when you click the link, it ends up going to a page on your site after its verified. How can I set what page it goes to?

推荐答案

您可以通过指定 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.

这篇关于验证时返回 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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