question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A question about building the FTL files

See original GitHub issue

Hope you don’t mind the question, I wasn’t sure where else to ask it.

As part of the “build” process, you are attaching variables on to a global object called kcContext (window.kcContext).

This is fine and works great.

As part of my task I have to migrate not only the login related pages, but also account pages as well. For example, I have an account page that allows the user to change their email address. Here is the code that links the user to that page;

            <@inputs.input id="username" name="username" type="text" value="${(account.email!'')}" class="input_withOption" disabled="true" labelText="Email address" hasOption="true">
                <@buttons.link href="${email.emailPage}" class="inputOption inputOption__link" importance="tertiary" gaId="updateLoginDetails_changeEmailButton">Change</@buttons.link>
            </@inputs.input>

We display the email address and provide a “Change” link. We pre-populate the email address field with the email they used for their account.

The account object is provided I believe from Keycloak. Currently it is not exposed by Keycloakify, even though I assume it is available.

So I was looking at this code;

<script>
    Object.deepAssign(
        window.kcContext,
        { "pageId": "login-reset-password.ftl" }
    );
    Object.deepAssign(
        window.kcContext,
         
{
    "realm": {
        "loginWithEmailAllowed": (function (){

            <#attempt>
                return ${realm.loginWithEmailAllowed?c};
            <#recover>
            </#attempt>

        })()
    }
}

    );
</script>

Specifically this;

            <#attempt>
                return ${realm.loginWithEmailAllowed?c};
            <#recover>
            </#attempt>

This is compiled by keycloakfiy.

Is there any way I can easily extend the build process so that I can output my own variables?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
jpreecenbcommented, Jun 7, 2021

@garronej thanks for the response! I’m happy to help out and contribute back to this library, as its heavily relied upon in our project. I’ll probably fork the project, add in the functionality that I need and try and come up with a good generic solution that I can contribute back.

All the best! Great project btw, good work!

0reactions
garronejcommented, Mar 2, 2022

It is not currently scheduled but this is something I would like to get in eventually.
What is coming next is the support for customising email. It’s very much possible that it unlock the possibility of customising account at the same time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using FreeMarker templates (FTL)- Tutorial - Vogella.com
In FreeMarker you define templates, which are text files that contain the desired output, except that they contain placeholders like ${name} , and...
Read more >
ftl - Apache FreeMarker Manual
Description. Tells information about the template for FreeMarker and for other tools, also helps programs to automatically detect if a text file ......
Read more >
What are FTL files - freemarker - Stack Overflow
Following files have FTL extension: Family Tree Legends Family File; FreeMarker Template; Future Tense Texture. Share.
Read more >
FreeMarker Common Operations - Baeldung
We can use the FreeMarker Template Language, also known as FTL, to generate many text-based formats like web pages, email, or XML files....
Read more >
Server Developer Guide - Keycloak
The createForm() method you called within authenticate() of your Authenticator class, builds an HTML page from a file within your login theme: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found