问题
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