Calling rest endpoint before rendering dom

Enonic version: 4.7.11 YourEnonicVersion
OS: YourOS


We have some “closed” enonic landingpages where the content should only be seen if the user has a certain membership. This membership data is stored in an external database and can be accessed using calls towards certain rest-endpoints. So far all the closed landingpages has been written in React.js so there hasnt been any issue. But now we want to be able to publish enonic content into those closed areas, which doesnt seem like an easy task.

Based on what i read so far, there isnt any way to pass the xml data into any react.js or .js which is to render the dom, nor run a ajax call toward the endpoint and then transform the dom using xslt. But perhaps some cleaver people have found a way around? Or do anyone have any suggestion?

Thanks in advance.

for 4.7 the simplest way would be to create a page (acting as an endpoint) that serves the XML you’re looking for? Not sure why this should be hard to do?

Thanks for the response, but how would I go forth to limit the access to the xml file when enonic doesnt have any direct access to the userdatabase?

The typical approach we been using for the .js part is:
1: prompt username and password dialog and send it to the rest-endpoint
2: get a accessToken in return
3: validate the accessToken against certain rest-endpoint each time the user enter a page that requires a certain membership status.

Hmm… I was under the assumption that the data was residing in an “external system”? Are you saying this closed content should now be stored in Enonic instead - or in addition?

Sorry, the initial post was badly written. I edited to make it easier to read.

But to sum it short,
I have enonic content that only a certain user should be allowed to see, the user data is stored in an external database and enonic have no direct access to that database.

I guess for this specific purpose and 4.7 creating a plugin would be the way to go. The plugin could do any kind of authentication (i.e. reuse your existing key system) and then deliver the desired content.