Email Template URL Calculation
My company uses FusionAuth's email templates for many tenants. We would like for each tenant to be able to point to several URLs through the email templates and for a calculation of the URL to be done within the template using Freemarker's replacement variables.
For example, a link in the email sent from tenant A should point to domains a.com and b.com and the choice of which to point to should be done dynamically depending on the site which sent the request.
Currently, this is made possible on forgot-password email requests through the passing of a state variable which contains the URL (or anything else). Unfortunately, the API does not allow for the passing of this state variable for other email requests, such as verify-email requests, which only allow access to the tenant and user objects.
And so, we've had to hard-code the URL into the email templates without a state variable, and tenants can only point to one domain as a result.
Is there a way to do this dynamic URL calculation in the email templates for email-verification, etc, which do not have this state variable?
joshua last edited by
In thinking about this, this almost sounds like a feature/extension. I will run this by my colleagues to see if they have any thoughts on it or a workaround/different approach!
joshua last edited by
After discussing this further, you may have few options (both with considerations and drawbacks) by either using the
userobject (which is available in some of the templates) and stuffing redirect/URL information in a custom
user.data'holder'. Another option, if your design allows for it, is to add additional tenants to allow for different forms to be used with different hardcoded URLs.
Of course, if this still does not meet your use case requirements feel free to log a feature request for our development team to consider.
I hope this helps!
robotdan last edited by
A couple of options:
You could optionally configure a different template for each tenant so you could hard code the correct URL in each template.
You could also add the correct URL to the
tenant.dataand then pull it out in the template during render so you could use the same template across tenants.
If the state parameter is working well for you for other APIs, you could open a feature request in GH to add this to the API in question.