How to refresh page data on user logout

HI

I have been able to setup a account creation form all works well and takes the user to a page which displays their details.

I have added a Logout button and seems to work, but the user data on the page does not refresh no matter what I try.

So the user data should disappear if the user is logged out. It works if I manually refresh the page.

I have tried a click event to reload the user data Action, but that does not work the user data is still shown.

I am sure I am doing something wrong but I am unable to reload the page data and from reading you can do this without reloading the whole page?
I have been following the webinar here: https://youtu.be/1NLr9eHowaI Webinar 3 Part 1 - Login, Logout, security provider

It also seems in the webinar it didn’t work either using a click event.

Can anyone share with me the correct way to refresh page data when a user logs in or out of the same page?

Cheers!

Hello,
What kind of data data are you trying to hide/refresh - where does it come from and how is it used on the page?

HI.

So It is in the user table and is:

  • firstname
  • email
  1. User logs in on a simple login page
  2. Takes the user to a new page and displays the data.
  3. On the page with the data there is a logout button
  4. Click the logout button and it logs the user out
  5. Success message is shown
  6. The page however with the two bits of data stays on the page
  7. reload the page manually it shows as expected.

So you don’t want to redirect users back from this page, after they are logged out? And it is not protected to auto-redirect if not logged users try to access it?

Yes correct. At this stage I just want to understand how to show the same page but when not logged in the user can not see the data.

After they have successfully logged out. The data on the page should not show.

In this case you can use conditional regions.
As a condition check the user identity, if it returns a value the conditional region content will be displayed - if not, it won’t be rendered.

ah ok, so it not shown it won’t Get the user data from the database?

Hi @StevenM You could use the browser component to refresh the page when the user clicks the logout button.

Just set the browser.goto as the same page as you want to refresh.

1 Like

Thanks @max_gb that worked! I couldn’t get it to work at the button level on click event for some reason but when attached to the form on ‘success’ worked as expected.

It’s supposed to be run onsuccess.
Events attached to the same button on click don’t wait for each other to complete. In order to be sure something happens after another, you need to run it exactly using the dynamic events - on done / on success.

Thanks @Teodor good to know this is how it’s supposed to work.