简体   繁体   English

更改流星电子邮件验证链接和路由

[英]Change Meteor email validation link and route

When Meteor sends the email with the link to validate the account, the link looks like this: 当Meteor发送带有链接的电子邮件以验证帐户时,该链接如下所示:
"//localhost:3000/#/verify-email/jOCevGxWbWQfcGL7KAtQ" “//本地主机:3000 /#/验证电子邮件/ jOCevGxWbWQfcGL7KAtQ”

If you click on the link it validates the account as a charm, but it sends the user to the 'ROOT' template. 如果单击链接,它将验证该帐户是否为超级按钮,但会将用户发送到“ ROOT”模板。
I want to change this route. 我想改变这条路线。 Clicking on the validation link have to route the user to another page, another then root route ('/'). 单击验证链接必须将用户路由到另一个页面,然后是另一个根路由('/')。

I have tryied changing the link adding a new template: 我尝试更改链接以添加新模板:
"//localhost:3000/template/#/verify-email/jOCevGxWbWQfcGL7KAtQ" “//本地主机:3000 /模板/#/验证电子邮件/ jOCevGxWbWQfcGL7KAtQ”
... and it works partially. ...并且部分起作用。
It verifies the account perfectly and routes the user to the right template... but this solution breaks all the images in this "template". 它完美地验证了帐户并将用户路由到正确的模板...但是此解决方案破坏了该“模板”中的所有图像。
What should I do? 我该怎么办?

Sounds like you got it, but I'll drop another option. 听起来像您明白了,但我会放弃另一个选择。 To change the URL you can do something like: 要更改URL,您可以执行以下操作:

Accounts.urls.verifyEmail = function (token) {
    return Meteor.absoluteUrl('verify-email/'+token);
};

And even better, you can eliminate that horribly long link by changing the email html: 甚至更好的是,您可以通过更改电子邮件html来消除冗长的链接:

Accounts.emailTemplates.verifyEmail.html = function(user, url) {
    var prettyEmail = "<a href="+url+">Click Me!</a>";
    return prettyEmail;
};

Make sure your images are referenced correctly. 确保正确引用了您的图像。 If your image is referenced using relative paths use an absolute path instead: 如果使用相对路径引用图像,请使用绝对路径:

ie

<img src="image.jpg"/> 
<img src="images/image.jpg"/> 

should be 应该

<img src="/image.jpg"/> 
<img src="/images/image.jpg"/> 

Ok, here's what I have done. 好的,这就是我所做的。
I've stopped concatenating the url and made a dynamic link within the rendered function to route the app to the page I want in the moment of the e-mail link validation. 我已经停止串联url,并在呈现的函数中建立了动态​​链接,以便在验证电子邮件链接时将应用程序路由到所需的页面。

Thanks Askhat your answer was right on the spot, because the images src need the "/" to work as well. 谢谢Askhat,您的回答是当场正确的,因为图像src也需要“ /”才能正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM