Hide/Show Buttons w/ Login/Logout

I am trying to hide/show login/logout buttons when users are logged in or not.

I am using the whoami method and setting the dynamic attributes based on if the whoami query is empty or not

Below are screenshots, any help would be much appreciated, I have been trying this for a couple of days. I tried watching tutorial videos over and over and still no luck.

API

ServerConnect

Login button

Logout button

I don’t know what

is, but you can simply check the identity of the user, if an identity is returned show the button, otherwise hide it. You can use conditional region for that.

I believe that is what I am doing... checking if the user identify is there or not but it isn't working.

Can you check is set / is not set?

just tested no luck :frowning:

I will have to go back and watch Ben and/or Brian's tutorials

Just curious, are you sure this is returning a value?

Screenshot 2024-06-07 at 1.42.49 PM

'Is Set' or 'Is Not Empty' should work.

How can I test, because I am starting to think my login is not working even though the success notification is working.

Surely you should be checking to see if there is any data within the query and not using the identity...

Something like:

 dmx-hide="conn_layout_whoami.data.query.hasItems()"

ugh.... I forgot I changed the name of my security provider and didn't update in my apis.....

thanks everyone

1 Like

Now off to figure out how to get the logout button to work...

Don't know if this is the perfect way:

I have an API that calls the security logout
And a page called logout.

So when: click on logout, then navigate to page logout where is a server connect to that API.
Also you can put a server connect with no auto load and call it with the button.

On dynamic success event of server connect, then navigate to: succesfully logout page

1 Like

PS: You can test and see the result of any server action, as they're APIS, so on your page.
Right click inspect.

  1. Go to network
  2. Fetch/XHR
  3. Reload the page or call the server connect again
  4. Find the API
  5. Click on Preview/Response to see what you need :slight_smile:

joys can't get the logout to work.... lol

Don't worry!
You can split this, and create a new topic for the logout part, so others can see what's going on and help you with that!
(Don't forget to mark your answer as a solution to this thread)