Can not logout

Hello,

I followed this instruction, but I can not logout correctly.

Please let me know how to solve this.

thanks,

Are you sure you are not calling some other event along with your sign out server action? Can you please paste the code of the log out button here?

Sure



The problem is with the empty href="" tag. It reloads the page, before the server action runs.
Either set it to: href="#" or href="javasript:void(0)" and remove the target="_self"

oh thanks, I fix those parts.

Still not working correctly.

I tried both href="#" and href=“javasript:void(0)”, and I got this though, “success” is not coming back, because success dynamic event doesn’t run.

It looks fine to me. The status is now 200 so it runs correcntly.
How do you have the onsuccess event set up?

I set onsuccess event like below.

and I still could see the user’s name which is not supposed to be shown up while being logged out.
(please see the previous image. “JOHN SMITH”)

So are you sure your logout action steps are correct then?

I would remove the <a> tags completely. If you’re using on-click events then there’s no need for the link.

in that case, how can I set “click” there?

Put the click event on the <li> tag instead.

I also create a class in my stylesheet like this:

.hover-hand {
    cursor: pointer;
}

and add that class to the <li> tag so you see the hand pointer when hovering over it so it’s obvious it’s clickable.

Currently I set like below.
is it ok to add another li tag?

<li dmx-hide="!getuserdata.data.query2.accountname"><a href="#" dmx-on:click="userlogout.load()"><i class="fas fa-sign-out-alt"></i> Sign Out</a></li>

Try this:

<li dmx-hide="!getuserdata.data.query2.accountname" dmx-on:click="userlogout.load()"><i class="fas fa-sign-out-alt"></i> Sign Out</li>

And if you want to use the pointer as mentioned in my previous post then it would be like this:

<li class="hover-hand" dmx-hide="!getuserdata.data.query2.accountname" dmx-on:click="userlogout.load()"><i class="fas fa-sign-out-alt"></i> Sign Out</li>

thanks, I tried your code though, still not working. 200 is responding but not goes through onsuccess event.

I don’t think the <a> tag is related to the error.
What steps exactly do you have in the server action?

My suggestion wasn’t to fix your logout issue, it was just to highlight you don’t need the <a> tag.

As I showed above,

  1. Click “SIGN OUT” -> Load Serverconnect
  2. Server Connect (Security provider -> Security Logout)
  3. Serverconnect on Success -> Browser alert -> Browser goto

Am I wrong?


Remove the security provider step from your server action… only use the global one

I removed Security provider, but still not working.