Navigation between containers

Hi,

My scenario: some pages within my main container are designed only for logged-in users. I wish to create a flow where a user clicks the link, if he is logged in, he will enter the page and if not, he will be redirected to the login page and after login in, he will be redirected to the previously selected page.

I have seen the logic within the default login page and I can see that it supports this scenario, but strangely: the redirecttoURL parameter is sourced from PageData

This is a bit strange as this data only exists within the container, so I would need to use AppData to pass it from the other container.

I have tried to use AppData for it, but something doesn’t work as I would expect. My current setup:

OnBeforePageEnter login on the page for logged in users:

Login on the login page:

Based on my understanding this should work, but it doesn’t. The AppData is not passed:

(one more thing: my logic is placed in “OnBeforePageEnter”, but still page is loaded within the browser and redirect is done after the page is displayed :frowning: )

Hi @Arkadiusz_Kumpin

UI Builder Containers are different applications that’s why they are not sharing the same AppData model.

However, since they are placed in the same app and use the same domain you can use LocalStorage to share data between them.

Regards,
Vlad

Ok, so I know how to pass data (I have used URL parameters, but for more data, LocalStorage looks great).

Now my question is: what is happening with the user session when moving between containers? I have managed to redirect the user to the login page, lig in, and redirect the user to the destination page, but it looks like the user is not logged in after moving from the system to the main container.

Is there any article / video on this?

If you use the Login page from the System container there is an option “Remember me”, enable it before login and the user token will be saved in the LocalStorage after the app refresh the system verify the saved token and restore the logged-in user

1 Like