Dynamic success event Show/hide buttons Login Logout

@Apple @karh

afternoon all, I have a quick (I hope) questions regarding dynamic success events. I have two buttons Login and Logout. I would like to upon successful login have the button Login hide and Logout show. and the opposite happen when logged out successfully.

I assumed I would create the on success hide button, but when I create the event there is no Hide option attached to the button.

What is the Wappler way of accomplishing this?

You can see from the attached image there is no hide

Not sure if there is an easier way to do it but an easy way I have done that in the past is to simply:

1: Create a single query to retrieve logged in user details
2: Refresh server connect on success
3: Hide login button if record exists
4: Show logout button if record exists.

1 Like

I normally do pretty much what @brad does, my only difference is I check the security identity step and not a single query but either should work fine

Thanks guys, and I understand that. I get that work flow process. My issue is that I do not see the show hide option under the button Upon success action. If that makes sense. Not sure why that option is not available.

You can use the dynamic show attribute on the buttons to check the identity or a single query returned by the server connect

The success events would want to be on the login and logout forms to refresh the server connect so the data is updated

@Sorry_Duh

Sorry, one big note here (I keep forgetting that most users use the server side on Wappler) I am not using the wappler server. I am using our company server and submitting an API form. On success the session token is stored in the session manager. I am have all this set up and working, the issue is that once the session token is stored and the user has been logged in I want the buttons to switch.

Are you saying this is the same process or does this change the methodology on how to accomplish the switch from login to logout?

You should just be able to use the dynamic attributes to show and hide the buttons if session variable exists.

Great that worked!

One other question, I have created an API action on click dynamic event to log the user out. For some reason it is not running the API action.

 <button id="btn3" class="btn btn-primary accountLogin btnPM btn-sm d-none d-lg-inline-block" data-bs-toggle="button" dmx-on:click="run({'api.send':{url:'http://3.15.46.23:3500/endsession',method:'POST',headers:{key:`key.value`},params:{token:`session1.data.token`},dataType:'x-www-form-urlencoded',name:'endsession',output:true}})" dmx-show="session1.data.token" dmx-hide="">Logout</button>

also see below images of how I set the button up.

Screen Shot 2023-01-20 at 2.11.56 PM

any suggestion as to why that is?