use of org.keycloak.theme.beans.LinkExpirationFormatterMethod in project keycloak by keycloak.
the class FreeMarkerEmailTemplateProvider method addLinkInfoIntoAttributes.
/**
* Add link info into template attributes.
*
* @param link to add
* @param expirationInMinutes to add
* @param attributes to add link info into
*/
protected void addLinkInfoIntoAttributes(String link, long expirationInMinutes, Map<String, Object> attributes) throws EmailException {
attributes.put("link", link);
attributes.put("linkExpiration", expirationInMinutes);
KeycloakUriInfo uriInfo = session.getContext().getUri();
URI baseUri = uriInfo.getBaseUri();
try {
Locale locale = session.getContext().resolveLocale(user);
attributes.put("linkExpirationFormatter", new LinkExpirationFormatterMethod(getTheme().getMessages(locale), locale));
attributes.put("url", new UrlBean(realm, getTheme(), baseUri, null));
} catch (IOException e) {
throw new EmailException("Failed to template email", e);
}
}
Aggregations