Change Meteor email validation link and route

跟風遠走 提交于 2020-01-03 03:04:25

问题


When Meteor sends the email with the link to validate the account, the link looks like this:
"//localhost:3000/#/verify-email/jOCevGxWbWQfcGL7KAtQ"

If you click on the link it validates the account as a charm, but it sends the user to the 'ROOT' template.
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"
... 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?


回答1:


Sounds like you got it, but I'll drop another option. To change the URL you can do something like:

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:

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



回答2:


Make sure your images are referenced correctly. If your image is referenced using relative paths use an absolute path instead:

i.e

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

should be

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



回答3:


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.

Thanks Askhat your answer was right on the spot, because the images src need the "/" to work as well.



来源:https://stackoverflow.com/questions/23683250/change-meteor-email-validation-link-and-route

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!